Nifty hidden shapes in a Codejam problem

2018/10/13

I was trying to solve a problem called How Big Are the Pockets? from Codejam.

Basically they want you to count the number of shaded squares in a figure like follows.

They give you as input a sequence of movements (right, left, or forward):

9
F 6 R 1 F 4 RFF 2 LFF 1
LFFFR 1 F 2 R 1 F 5

In order to debug my solution I made a program that draws the line path and a trace of my solution.

I found some cool figures in the input test cases.

3.png

This one looks like a face:

2.png

>> Home