Back
Close
  • 48

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

Your job is to extend the Logo language developed in ASCII Art with Logo Language by giving the Turtle the ability to move diagonally and some new commands (to check your first implementation's resiliency to the never-ending dance of changing requirements).

Commands from part one (not modified):
CS character: CLEARSCREEN. Clears the screen with the specified symbol (only printable ASCII excluding space).
FD times: FORWARD. Moves Turtle forward for number of times specified (only positive integer).
PU: PENUP. Sets the Turtle to move without drawing.
PD: PENDOWN. Turtle leaves a symbol when moving.

Modified commands:
SETPC pen: uses cyclically the characters in pen as Turtle pen, changing every Turtle's step (of length 1) with pen down. Default value for pen is #. ;, [ and ] cannot be used in pen. The index for cycling characters resets each time you use SETPC.
RT angle: RIGHT. Turns Turtle right for number of degrees specified (only positive multiples of 45).
LT angle: LEFT. Turns Turtle left for number of degrees specified (only positive multiples of 45).

New command:
RP loop [[commands‎]]: REPEAT. This instruction repeats commands the number of times indicated by the loop parameter.

For example:
RP 2 [FD 2]
is equivalent to
FD 2;FD 2

REPEAT can be nested. For example:
RP 2 [RP 2 [RT 90;FD 2]]
is equivalent to
RT 90;FD 2;RT 90;FD 2;RT 90;FD 2;RT 90;FD 2

setpc 12345;rt 90;fd 5

produces
12345

As in part one, Turtle starts heading North, with the pen down and the initial symbol set to #.

Reference Part 1:
https://www.codingame.com/training/medium/ascii-art-with-logo-language
Input
Line 1: An integer N, indicating the program's number of lines.
Next N lines: lines of text with Logo instructions.
Output
The ASCII Art generated.
Constraints
1 ≤ N ≤ 10
angle: a positive integer multiple of 45.
loop: a positive integer from 1 to 100.
pen: an ASCII string excluding spaces, ;, [ and ].
Example
Input
2
rt 45 
fd 5
Output
    #
   #
  #
 #
#

A higher resolution is required to access the IDE