- 44
Statement
Goal
The program must output the result of tumbling a landscape a certain (large!) number of times.Tumbling entails:
ββ rotating the landscape counterclockwise by 90Β°
ββ letting the hash bits
The map is composed of
But wait⦠we're going to be tumbling the landscape so many times we might not live to see the result! So instead of just typing the number of tumbles we want on a simple Gravity Tumbler, we're going to use a Gravity Centrifuge and its much improved tumbling capacity, relying on twin inertial drives and their incomparable frictionless movement induction.
The twin inertial drives are programmed with a bitstream used as such:
ββ Both drives are gotten to roll with an initial momentum of
ββ The bits operate on the drives in alternating order, from least significant bit on. So bit 0 controls drive A, bit 1 drive B, bit 2 drive A again, and so on.
ββ When the bit is set, the drive tumbles the landscape around as many times as the current value of its momentum. It's all done by frictionless induction, so the drive's own momentum is unaffected.
ββ Simultaneously and regardless of bit value, the drive accelerates its twin by the current value of its momentum. Its own is still unaffected.
ββ Control then shifts to the other drive for the next bit in the stream.
For convenience (and input size limitations), the operation bitstream is provided in octal. Yes, twin inertial drives are a wee bit baroque.
Example
Using binary bitstream
ββββββββββ¬βββββββββ¬ββββββββββ¬βββββββββββββββββββThe bitstream is then fully consumed and operation can stop. The landscape has been tumbled
β A mom. β B mom. β Tumbles β Action β
ββββββββββΌβββββββββΌββββββββββΌβββββββββββββββββββ€
β 1 β 1 β 0 β 0 => no A tumble β
β 1 β 2 β 0 β A induces 1 on B β
ββββββββββΌβββββββββΌββββββββββΌβββββββββββββββββββ€
β 1 β 2 β 2 β 1 => 2 B tumbles β
β 3 β 2 β 2 β B induces 2 on A β
ββββββββββΌβββββββββΌββββββββββΌβββββββββββββββββββ€
β 3 β 2 β 2 β 0 => no A tumble β
β 3 β 5 β 2 β A induces 3 on B β
ββββββββββΌβββββββββΌββββββββββΌβββββββββββββββββββ€
β 3 β 5 β 7 β 1 => 5 B tumbles β
(B would induce 5 on A here, but we're done anyway)
ββββββββββ΄βββββββββ΄ββββββββββ΄βββββββββββββββββββ
(This puzzle is a βharderβ version of community puzzle βGravity Tumblerβ. You may want to solve that one first.)
Input
Line 1: two space-separated integers: the map width and height
Line 2: the operation bitstream, in octal form
Next height lines: width characters (empty bits. and heavy bits # )
Line 2: the operation bitstream, in octal form
Next height lines: width characters (empty bits
Output
For an odd tumble count: width lines of height characters where the # are at the bottom.
For an even tumble count: height lines of width characters.
For an even tumble count: height lines of width characters.
Constraints
0 < width β€ 100
0 < height β€ 100
0 < number of bits β€ 29999
The input map is in a βstableβ configuration, i.e. the heavy bits are already at the bottom.
0 < height β€ 100
0 < number of bits β€ 29999
The input map is in a βstableβ configuration, i.e. the heavy bits are already at the bottom.
Example
Input
17 5 1 ................. ................. ...##...###..#... .####..#####.###. #################
Output
....# ....# ....# ....# ....# ...## ...## ...## ...## ...## ...## ..### ..### ..### ..### ..### ..###
A higher resolution is required to access the IDE