23
6
Everybody loves geometry. So why don't we try and code golf it? This challenge involves taking in letters and numbers and making shapes depending on it.
The Input
The input will be in the form of (shapeIdentifier)(size)(inverter)
.
But what are shapeIdentifier, size, and inverter?
The shape identifier is the identifier for the type of shape you will be making with *
s. The following are the shape identifiers:
s
- Squaret
- Triangle
The size will be between 1-20
, and it is the size of the figure.
The inverter is whether or not the shape will be upside down, which is denoted by a +
or a -
. Do note: s3-
== (equals) s3+
because squares are symmetric. However, t5-
!= (does not equal) t5+
.
Trailing whitespace is okay in the output but leading whitespace is not.
Output Examples
Input: s3+
Output:
***
***
***
Input: t5+
Output:
*
***
*****
Input: t3-
Output:
***
*
Special Notes
The triangle input will always be an odd number, so the triangles will always end with 1 *
at the top.
The size of the triangle is the size of the base if the inverter is
+
and is the size of the top if the inverter is-
.
3As someone who is taking Geometry right now, (and studying for a Geometry final), I can say with 100% certainty: Geometry is absolutely, not fun at all... D: – Ashwin Gupta – 2016-01-22T03:28:01.013