DWITE '09 R4 #3 - Moving at the same time

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE Online Computer Programming Contest, January 2010, Problem 3

Silly title, but this is exactly what this question addresses. There are too many questions on the CompSci.ca forums asking just that -- "I have 2 (or more) characters in my game, how do I move them both at the same time?" This should be obvious to some, and might sound more complicated than it is to others. Maybe the constraints of this question will provide a clue?

The input will contain 5 lines, each line will describe a game field and characters on it. The size of the field is the size of the line, 1 \leq N \leq 20. Periods are empty spaces, while integers 0 \leq C \leq 3 are Characters. The value of the integer represents that character's speed, in the direction to the right of where they are. Ones the character leaves the field, we are no longer concerned with that character. If two characters end up on the same spot, represent them as a sum of their velocities. In the initial input, all of the characters are distinct, and it is guaranteed that the overlapping sum is never greater than 9.

The judge is the observer of the game. Each output line is judge's perception of the game (that is, each output line is a frame of this game's FPS (frames per second)). If a character's velocity is 2, then in time from one frame to the next, that character moves 2 spots to the right.

The output will contain 5 sets of 5 lines each, the snapshots of the gamefield for each game as it progresses, starting with the input, and following with 4 frames.

Sample Input


Sample Output


Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


  • 14
    bruce  commented on May 3, 2019, 9:52 p.m.

    In the initial input, the characters may not be distinct.