Python  1.0
Functions
_08c_rightTriangle Namespace Reference

Print the right triangle with the length of two of its sides equal to a given value \(n\), using the symbols + and =, in each of its four possible orientations. More...

Functions

def rightTriangle (n, orientation=0)
 Return a string representing the right triangle of height n in a given orientation. More...
 
def getAllTriangles (n)
 Generates and interleaves all four orientations for printing. More...
 

Detailed Description

Print the right triangle with the length of two of its sides equal to a given value \(n\), using the symbols + and =, in each of its four possible orientations.

For instance, if n=5, the output should be:

 +====  +++++  ====+  +++++
 ++===  ++++=  ===++  =++++
 +++==  +++==  ==+++  ==+++
 ++++=  ++===  =++++  ===++
 +++++  +====  +++++  ====+
 
Author
Paulo Roma
Since
13/05/2018
See also
https://en.wikipedia.org/wiki/Right_triangle

Function Documentation

◆ getAllTriangles()

def _08c_rightTriangle.getAllTriangles (   n)

Generates and interleaves all four orientations for printing.

Parameters
ntriangle height.

References _01d_dec2bin.input, and rightTriangle().

◆ rightTriangle()

def _08c_rightTriangle.rightTriangle (   n,
  orientation = 0 
)

Return a string representing the right triangle of height n in a given orientation.

Parameters
ntriangle height.
orientation0 up, 1 down, 2 right, 3 left.

Referenced by getAllTriangles().