18
2
The challenge
Write a program or function that prints stars! The program will receive two parameters by standar input: Size of the star and number of points of the star. A star can be any size between 0 and 10 and have 3, 4 or 5 points. The input parameters are separated by a comma, for example: 5,3
means a size 5 star with 3 points. The stars are composed by asterisks *
Consider the program will only receive valid inputs.
The prints must be correctly spaced so we can see pretty stars in the output!
Parameters explanations
Points
Is the number of arms counting from the central asterisk.
3 points stars:
*
*
*
* *
* *
They are composed by a vertical arms and two diagonal arms. The separation between diagonal arms is 2*size-1
4 points stars
* *
* *
*
* *
* *
They have the form of a X and composed by two diagonal lines. The separation between lines is 2*(size-1)+1
5 points stars
*
*
* * * * *
* *
* *
They are composed by a vertical line and a horizontal line. Each asterisk in the horizontal line is separated by one space. Also they have two diagonal lines, with a separation between themselves of 2*(size-2)+1
Size
Size is the number of asterisks that has each arm of the star counting from the central asterisk (inclusive).
Size 1 stars are composed by a single asterisk
*
Size 2 stars examples
3 points
*
*
* *
4 points stars
* *
*
* *
5 points stars
*
* * *
* *
You have examples of the size 3 stars in the Points parameter explanation.
Winning criteria
Shortest code wins. Code have to be checked with the following input parameters: 3,2
3,3
4,2
4,3
5,2
5,3
Bonus
-25% characters count for creating a size 6 pointed with the criteria explained before (6 arms and the size is the number of asterisks counting from the central asterisk). It can be any form you want while it respect the specifications. A example of a size 6 star with size 3:
*
*
* * * * *
* * *
* * *
6 points stars must be checked with the following inputs 6,2
6,3
.
1In your first example of a (5,3) star, should the two horizontal points each be one asterisk longer? – PhiNotPi – 2012-08-28T22:43:55.493
Yes, it is. Fixed, Thanks! – Averroes – 2012-08-29T06:15:22.793
3"My God... It's full of stars" – Drake Clarris – 2012-08-29T13:52:42.597
That should be the question title! – luser droog – 2013-04-07T06:53:02.353