If you're not familiar, Dance Dance Revolution is a rhythm game where you hit four receptors (left, down, up, right) with your feet as arrows scroll up the screen. One of the file formats used to lay out the arrow patterns looks something like this:
1000
0100
0000
0011
,
A 1
represents a tap note. This chart has a left tap, a down tap, an empty line, and an up-right jump, respectively. The comma at the end indicates the end of a measure, and there can be any number of measures in a song.
Now here's an example of a more complicated chart:
1000
0010
0100
0001
0010
0100
2000
0000
,
0010
0001
3100
1001
,
The first measure has eight lines, so each line represents an eighth note, but the second measure only has four lines, all of which are quarter notes. All measures are the same duration; measures containing more lines are simply denser. You can assume that all measures will have lengths that are powers of two greater than or equal to 4. So measures can have 4 lines, 8 lines, 16 lines, and so on.
A 2
indicates the start of a hold arrow and a 3
represents its end. You can assume that each 2
will have a corresponding 3
in the same column, without anything between them other than zeroes and/or measure boundaries.
Your task is to print the stepchart in a more human-readable format. It's probably best if I just give you an example. Here's the expected output for the chart given above:
<
^
v
>
^
v
<
|
| ^
|
| >
|
|v
< >
(If this is confusing to you, perhaps looking at this will help.)
Left, down, up, and right taps are indicated by <
, v
, ^
, and >
, respectively. Hold arrows are indicated by pipes that trail beneath the starting taps.
Additionally, the chart needs to be stretched so that each measure is the same length: in the above example, the measures have lengths of 8 and 4, so the output shows all measures as if they contained eighths. If you have a chart where all measures are 4 lines long except for one that's 64 lines, the output needs to render all measures as 64 lines long!
I/O: Assume the chart exists in a file whose name is given as the first argument to the program (e.g. python arrows.py input.txt
). Write to standard output. If (and only if) your language of choice doesn't have filesystem access for whatever reason, it's acceptable to load it as a string at the beginning of the program.
Goal: The program with the fewest characters will be accepted a week from now, the 17th of August, around 8:00 EST.
3
because otherwise, if there were a2
immediately followed by a3
, it would look identical to a tap note. You don't have to handle invalid input (bad filename, malformed chart data) in any way. \$\endgroup\$ – Fraxtil Aug 11 '12 at 6:54