Mock CCC '18 Contest 2 J2 - A Software Engineering Task

View as PDF

Submit solution


Points: 4 (partial)
Time limit: 5.0s
Memory limit: 1G

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

You are given a 2D array with n rows and m columns and asked to run the following procedure on it 100 times.

function(grid):
for each row in the grid going from top to bottom:
    for each column in the grid going from left to right:
        if the character in the given row and given column is an 'o' and the character in the same column and one row lower is an '.':
            swap those two characters in the grid

Print out the grid after running the procedure 100 times.

Constraints

1 \le n, m \le 50

In the array, the only characters that will appear are o, #, and ..

Input Specification

The first line contains two space-separated integers, n and m.

Each of the next n lines contains m characters describing the array from top to bottom.

Output Specification

Print the grid in exactly the same format after 100 simulations of the above procedure.

Sample Input

3 3
ooo
#..
..#

Sample Output

o..
#.o
.o#

Comments

There are no comments at the moment.