I thought it'd be interesting to turn AoC day 3 puzzle into a Golfing Challenge, so here it is.
Task
Find the number of #
you'd encounter in an 11x11 grid (consisting of #
and .
) that repeats itself (to the right side), starting at the top left corner, which is always a .
. You will need to check the position that is \$x\$ right, \$y\$ down, then the position that is \$x\$ right, \$y\$ down from there and so on until you reach one of the bottom #
or .
.
Input
Two arguments:
3,1
-
..##....... #...#...#.. .#....#..#. ..#.#...#.# .#...##..#. ..#.##..... .#.#.#....# .#........# #.##...#... #...##....# .#..#...#.#
means that you should traverse the grid going 3 right and 1 down. The output should be 7
(see the example in the AoC link above).
Without changing the grid but only the positions, here are some example inputs and outputs:
- \$x=1, y=1 \to 2\$.
- \$x=5, y=1 \to 3\$.
- \$x=7, y=1 \to 4\$.
- \$x=1, y=2 \to 2\$.
1,1
-
.........## .#.#....... #.......#.. .........#. .....#..... ...##...#.. #.#..#....# ........##. ......#.... ...####...# .........#.
means traversing the grid going 1 right, 1 down each time. You'd encounter only 1 #
in this example, so the output should be 1
.
Rules
- \$x\$ (right) and \$y\$ (down) will be positive integers, where \$y < 3\$ (no limits for \$x\$).
- The grid can be repeated unlimited times.
- You can replace
.
and#
with whatever you like in the grid (e.g.0
/1
). Just mention which corresponds to which. - You can receive input through any of the standard IO methods.
- This is code-golf, so shortest code in bytes wins!
0
and1
correspond to. \$\endgroup\$