Skip to content

Commit

Permalink
Day 2
Browse files Browse the repository at this point in the history
Signed-off-by: Robbe Pincket <7889478+Kroppeb@users.noreply.github.com>
  • Loading branch information
Kroppeb committed Dec 3, 2020
1 parent 694f8b7 commit 4b0bdf9
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 27 deletions.
323 changes: 323 additions & 0 deletions solutions/resources/2020/3
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
.#...#.......#...#...#.#.#.....
####.....#.#..#...#...........#
.....#...........#......#....#.
......#..#......#.#..#...##.#.#
............#......#...........
...........#.#.#....#.......##.
....#.......#..............#...
........##...#.#.....##...##.#.
.#.#.....##................##..
.##................##..#...##..
....#...###...##.........#....#
.##......#.........#...........
...#.#.#....#....#...#...##...#
..#....##...#..#.#..#.....#.#..
.......#...#..#..#.....#...#..#
.....#......#.......#.....#.#..
....#..#...#..#####....##......
.#...........#......#....#....#
#......#.###.....#....#....#...
....#..#.#.#..#...........##...
..#..#..#.#...#......#....#.##.
.##....#......#...#.#..#.......
..###.#...#.........#.#.#...#.#
#....###.........#...#...#...#.
...##.#............#...##......
...#.........#............#....
......##...#...##..#...........
........##..#.#.####...#.....#.
.##.........#......#..#..#...#.
..........#...#..........#.....
#..........#........#..#..#.#..
..#....#.#.#.#.#..#.##.........
##.#.#.##.....#..#......###....
##....#...#.....#..............
.#..#...#...#....###......#....
#....#......#.#..#.#........###
.#....#..#...###....#...##.....
.#....#.....#.....#..##..#.....
#....#.##...#...#..#.##.##.#...
.#.#.#.##...#####.............#
......##..#.....##..#...####...
#.##..#.#....#..##.......###..#
..#.......##....#........#.##..
#.....#......#.....#....#..#...
.......##...#.....##.......#..#
.......#...#.#.#.........#####.
#.......#.##..##........##.....
##..#...#........##....#.......
.......#...##......##...##.##..
......#..##..#.#...#...#....##.
....#.#..#.....#.##.#.....#.#..
#..#.#.#........#...#.......##.
##...........#..#........#.....
....##....#....#.#.......#.....
....##.#.#.....#.#.....#.....#.
..........#.#..##..#..#.......#
#....#.......##...#...#.....#..
.........##.....#.#....#......#
..........#........#..#..#.#...
..#......#.....#......#......#.
..#...###..##..#.....##..#..##.
..#.#..###.........#.#...##.#.#
#.........#..#......#...##.....
...#...#.#..#...##.#...##.#..#.
#.....#.....#.##....#.#......#.
#....##..##..#.#..##....#.....#
.#..........#..#...#..#.......#
#.#.....#..##..##..#.#.........
....#..##...#.....#.....#.#.#.#
...#.#....#........#...#.#.....
.#............#.......#.##.#...
..##.......#.#...#........##..#
..................##.#...#.#..#
.#.........#.......#.....#.....
....##...##..#..........#......
..#.##..#....#..#............#.
....####...#.##....##.#....#.##
#..#....#......##........##....
..###...........##..#......#...
#..#.......#........#.......#..
.....#....#..#..##.....#.......
.###.####.#....#....#..#.......
.............#...............#.
.#..........#.#....#..#.#......
..............##....#..#....##.
.......#.#..#........#.......##
#..#...#..#.#........#..#....#.
...#.........#...#..#..........
...#....##...#..#..........#...
.#......#......##..##...#.#....
.#.........#..###..............
.................#.#.....##....
...#............#..............
#..#................#.......#..
...#.......#......#.#.#........
#.....#.##....#.....#........#.
......##.#....#........#....#..
.#..#.##...##........#.#.....#.
..#...#....#...#..#..##..#.#..#
#.................#.#.......##.
..........#........#.#.....#..#
#....##....#........##..##.#...
#...#....#.....#.....#.....#...
#..#..........#....##....#....#
..#.#..#..#....#.#....#....#..#
#....#..#.......#..........#...
.#...#.#...#..#...#.......#....
###........#......##..#...##...
...#..........##..............#
.......#........##......#.....#
.#..........#...#...##....###.#
.#...#....#..#.....##...#..##..
.#.#.#...##..........##...#...#
.#.....#...#........#........##
#.......#......##.#.#..#....#..
##..#.##........#....#..#......
...#.......................#...
..#....#..##........##.#.##.#..
.............#.......#....#.#.#
...#...........##..#.....#.....
..#....##....#.....#...........
..#.....#......#..#.###.##....#
.#.......#...........#...#....#
#............##...#...#.....#..
##...#.....#.........##...##...
...#...........#....##.........
#.##..#..........##..#......#..
.......#.#.......##.......#....
..#.....##..#...#.......#......
.#........#....##...........#..
#.......#...#.#.###...#....#...
..........##..#..#..##........#
#....#....#...#....#....#......
...........#....#...#...##.#...
.........#.#.....#.............
..####...........##..........#.
.....#...................#.....
#..##...#........#.###.#.##....
....##...#.##................#.
.#........###.#............#.#.
..............#.##.........#...
##............#.#..###....#...#
#.....#........####....#....##.
....##..#...##..##...##.....#..
##..#....#.##.....####.....#.##
##..#....#.##.##.#.#........#..
....#..........##.....#..#..#..
...#.......#........#.........#
#..##.######.......##........#.
###...#...####.......#.....#...
#......#..#.....#......#.....#.
..................##...#.......
....#.#....#......#...#.....##.
..#..#..#..#..#....#.#...#....#
......#....###.................
#.##......#...#......#.........
#..#.#...##..#.......#..#...#..
.#....#.#........#.........#...
#.......##..#..#...............
........#..##....#.....#..#....
....#......##..#....#...#..#...
#.....#...##..#...#......#.....
.....#.....#.........##...#..#.
........#...##.#...#.#....#..##
....#....#...#.....##..#...#...
#....#..#.........#.........###
..###.....##...#.#....##......#
#..#.#..#.......#..#....##.....
###...#.##..#.......#......#...
.....#.....##.......#...##..#..
......#.......#.#.#......#..#..
.................##..#.###.....
..........#....#...#..........#
...#.#...#.#..##.....#.#.##..#.
.......#..#....#...#......###..
...##..........#..#.....#....#.
.#..##..###...#....##.....#....
..#.#..............#....#...#..
.....####.......#.#.##....#....
#.#.#..##.##.#..#.##.#....#..#.
........#....#.......##........
...#...#....#...###.....###....
.....#..#..........##.#...##.##
..#.#.#..#....#...#..##...#...#
..#......#..#.#.....#....#....#
.#.....#.......#............#..
#..##....#...#....##....#......
#..#.........#...#...###.#..#..
..#.#.#..#.#..#.......##.......
...##...............#..#...#.#.
.......####.#.....#..#..#......
......#..#.....#..##....#......
....#...#.........##.......#.#.
#.#.#...#.....#...#..#.#..#....
........#..#.........#..#..##..
........###.#............#.#...
#..#.......#.#..#.......#...#.#
..##..............#.#.....#...#
..##...........................
..#.....#.......#......##......
#...#......##.#....#.#.#...##.#
#...#.#......#.#..##.........#.
.##..#...#.#.....#.#.#...#.#..#
.#..#...#.#.........#......#...
...........#...#...#...#..#.#..
.#........#...#......##...#.###
#........#..#.#..#...........##
.#...#...####.......#..........
......#...............#........
.....#.#.....#.#...#......#....
.#........#...........#..##.#..
....#..#.....###.......#...#...
#.#.........#...##..#.#.##.#...
................##.#....#.#...#
.......#.......#......#...#....
#....#.#..............#.##..###
..##.##..#.....#............#..
#....#..##........#....#.......
.#.#........#.#................
......##..#..#..........#..#.#.
.....##.#..#....##.#......##...
........###.#................#.
#..###.....#.###.#...#.#.......
.#..#.#.#.#..#..#.#.....#.#....
#....#.....#..#......##...#..##
........#...##..#.#.....#....#.
.......#..#..#..#....#.....##..
....#..##..#...#....#.........#
#.#....#..#.#...#.#...#....#...
.....#......###.......#..##.#.#
.......##.....#....#........#.#
.##.##..#..###.#....#.#.....#..
..##.#.......###.........#.....
.#...#......#..#....#..........
.....#........#.....##...#.....
..#......#.#.#..#.#....##.#...#
#.#...#...........##......#....
.................##.....#.#.##.
###..#....#..................#.
##..#.#.#...#....###.#.#...##.#
#.#.#..#....#..............#...
.....#....#......#..#.##.......
#...#...#..###.......#.......#.
.....#.#........#..#...#.#.....
.....#..........#.###.......#..
...#.##.....#....###.....#.....
####........#....#..#.#.##.#...
#......#...##.....#.#..##.#.#.#
.....##....#..#.........##.....
..##....##................##..#
#.....#...##...##.#.....#...#..
..#..#.#.#....#.#.......#......
##.....##......#...#.........#.
#..........#........#.#......#.
.#..#.......#.#.....#..........
.........#.#.......#.#..#..#..#
#......#....#....#..##..##...##
.....#..#...#.......#.....##...
..#.##........#.###...#...#...#
..#..#...........#..........#..
.#.#.#...#.##.#..............#.
....#..##.......#.....#..##..#.
.#.##.#....##........#...##.##.
...#.#...#....#....#......#####
.....#.....##...........#......
#........#.##.......#.#.......#
#...#.......##.#.......#..#.#..
#...##..#....#............#.#..
........#.#..#...#..#...##..##.
#...#....#............#........
#.#.#.#.#....##.....##.........
......##.........#.......#.#..#
...#.#....#........#...........
...#.#.......#.....#...........
##....####......##.##..#.......
#......#...#..#.#..#......#..#.
#......#.#....#....#..#........
..#.###...#.....#........#.#...
..#.....##.....###....#.....#..
#.##.#.....##....#...###.......
###.#....###.#..##.#.......##.#
#..#..##...#.#..........##.##..
.......####.#..#.....##..###...
#...#...##..#..##.......###....
#....#.........##..#.........#.
.....#.#..........#..#...#.#..#
..........#......##..#..#.#....
.#...#...#...#........###....##
#....#.##..........#.#.....#.#.
#....##.#.##..#.......#.#.....#
.##..##..#.#...#.#...........#.
....##..#...#.#.##.#.#...#.....
.#...#.##........#.##..#.#....#
.#.....##.........#.....#......
..#.....#.#..#.##.............#
##....##...#....##........#....
.#....#........#.#..#..#..#.##.
.#........#............#.......
.#..##..##..#..#..####....#....
..#.###....#..#.##......#.#...#
.###..#.#...##....##....#..##.#
....##........#....#.#.#...##..
...#..#....#.#....#...#.#.....#
...##....##..#....#.........#..
.....#..##.###..#.....####.....
...#..#.........#....#.#.##..#.
...#..#...............#..#....#
...........#.....#...####..##.#
..#......#...#....#..#...##.#..
.....#..#...........#.......#.#
##....###...#.........#....#...
...#..##.......#.#.....##....#.
#.#...#.#....#.....#...##.....#
.#...##....#.....#..##.......#.
...#........##..........#.....#
#...##..#.#....###...#..#......
............#.......#......#.#.
......#....#.#...#...#..#......
.#..#......#....#.......#....##
...#...#.......###..###...#....
.............#.#...#..###.....#
.#.....#........#...##....#..#.
.....#.......#######.#.#...#...
39 changes: 39 additions & 0 deletions solutions/src/solutions/y20/day 3 converted.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@file:Suppress("PackageDirectoryMismatch")

package solutions.solutions.y20.d03c

import helpers.*
import collections.*
import grid.*
import graph.BFS
import itertools.count
import kotlinx.coroutines.*

val xxxxx = Clock(3, 6);

private fun check(data: Data, q: Int, d: Int): Int {
var s = 0
for (y in data.bounds.ys step d) {
val p = q * y / d toP y
if (data[p % data.bounds] == '#')
s++
}
return s
}

private fun part1(data:Data) {
println(check(data, 3,1))
}

private fun part2(data: Data) {
val l = check(data, 1, 1).toLong() * check(data, 3, 1) * check(data, 5, 1) * check(data, 7, 1) * check(data, 1, 2)
println(l)
}

private typealias Data = CGrid

fun main() {
val data: Data = getCGrid(2020_03)
part1(data)
part2(data)
}
Loading

0 comments on commit 4b0bdf9

Please sign in to comment.