Back
Close
  • 448

Statement

 Goal

The program must output the result of tumbling a landscape a certain number of times.

Tumbling entails:
- rotating the landscape counterclockwise by 90°
- letting the hash bits # fall down

The map is composed of . and #.

(This puzzle is a twist (hah!) on classic community puzzle “Gravity”. You may want to solve that one first.)
Input
Line 1: two space-separated integers: the map width and height
Line 2: the number count of tumbling actions to perform
Next height lines: width characters (empty bits . and heavy bits #)
Output
If count is odd: width lines of height characters.
If count is even: height lines of width characters.

Obviously, in both cases, the # are at the bottom.
Constraints
0 < width < 100
0 < height < 10
0 < count < 100
The input map is in a “stable” configuration, i.e. the heavy bits are already at the bottom.
Example
Input
17 5
1
.................
.................
...##...###..#...
.####..#####.###.
#################
Output
....#
....#
....#
....#
....#
...##
...##
...##
...##
...##
...##
..###
..###
..###
..###
..###
..###
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants