mirror of
https://github.com/plasmaofthedawn/adventofcode.git
synced 2025-08-22 01:22:02 -05:00
added idk a bunch of junk
This commit is contained in:
141
resources/2024/day16.txt
Normal file
141
resources/2024/day16.txt
Normal file
@@ -0,0 +1,141 @@
|
||||
#############################################################################################################################################
|
||||
#.#.........#...#.....................#...........#...............#...#.................#...........#...#...#.....#.#...........#.....#....E#
|
||||
#.#.#.#######.#.#.#########.#########.###.#.#####.###.#####.#.###.#.#.#########.#####.#.#####.#.#####.#.#.#.#.###.#.#.#####.#.#.#####.#.###.#
|
||||
#...#.........#.....#.........#.....#.......#...#.........#.#...#...#...#...#...#.#.....#...#.#.......#...#.#...#.#...#.....#.#.#.....#.#...#
|
||||
#.###################.###.###.#.###.#####.#####.#####.###.###.#.#######.#.#.#.###.#.#.###.#.###.###########.###.#.#####.###.#.#.#.#.###.#.#.#
|
||||
#.#.....#.....#...#...#.......#.#.#.#...........#.......#...#...#.....#...#...#.#...#.....#...#.........#...#.#.#...#...#.....#.#.#.#...#...#
|
||||
#.#.###.#.#####.#.#.#####.###.#.#.#.#.#.#.#####.#.###.#.###.#.#######.#######.#.#.#.#.#.#####.#########.#.#.#.#.###.#.###.###.#.#.###.#####.#
|
||||
#.#.#.....#.....#.#.#...#.#...#.#.#...#.#.....#.#.#.....#...#.#.....#...........#.#...#.#.............#.#.#...#.#.#...#.....#.#.#...#.#...#.#
|
||||
#.#.#######.#####.#.#.#.###.#.#.#.#####.###.#.#.###.#.###.###.#.###.#.###.###.#.#.#.#.#.#########.###.###.#.###.#.#######.#.###.#.#.#.#.#.#.#
|
||||
#.#...#...#...#.....#.#.....#.#.#.....#...#.#.#.#...#.#...#.....#...#.#.#...............#...........#.....#.#...#.#.....#.#.#...#.#.....#.#.#
|
||||
#.###.#.#.###.#.#####.#######.#.###.#.###.#.#.#.#.#.###.###.#.###.###.#.#####.#.###.#.###.#####.#.#.#######.#.###.#.#.#.###.#.###########.#.#
|
||||
#.....#.#.....#.#.....#.....#.#.#...#...#.#.#.....#.#...#.....#...#.#.........................................#.....#.#...#.#...#...#.....#.#
|
||||
#####.#.#####.###.#######.#.#.#.#.#######.#########.#.#######.#.###.#####.#.#.#.#.#.#.#######.#.#.#.#.#.#####.#.#####.###.#.###.#.#.#.#####.#
|
||||
#.....#.....#.#...#.......#.#.#.#...#.....#...#...#.#.#.....#.#.#.#.....#...#.....#.#.#.....#.#.#.#.#.#.....#.#.#...#.#.#.#...#...#.#.#.....#
|
||||
#.#########.###.#####.#######.#.#.#.#.#####.#.#.#.###.#.###.#.#.#.#.###.###.#.#.#.#.#.#.###.###.#.#.#.#####.#.#.#.#.#.#.#.#.#######.###.#.#.#
|
||||
#.#...#.....#...#.....#.....#.#.#.#.#.#...#.#...#.......#.#.....#...#.#.#...#.#.#.....#.#.#.....#...#.#.....#.#...#.#.#...#.......#.....#...#
|
||||
#.#.#.#.#####.###.#####.###.#.#.###.#.#.#.#.#######.#####.#######.###.#.#.###.#.###.###.#.#######.#.#.###.###.###.###.#.#####.#############.#
|
||||
#.#.#...#.....#...#.....#.#...#...#.#...#.#...#.....#.....#.......#...#.#.#...#...#...#.#...#.......#...#.#...#.#.#...#.......#.....#...#...#
|
||||
###.###.#.#######.#.#####.#######.#.###.#.#.###.###.#.###.#.#########.#.#.#.###.###.#.#.#.###.#########.#.###.#.#.#.###########.#.#.###.#.###
|
||||
#...#...#.#...#...#...#...#.....#.......#...#...#...#...#.#.........#.#...#.....#...#.#.#.#...#.........#.....#...#.....#.......#.#...#.#...#
|
||||
#.###.#.#.#.#.#.#.###.#.###.###.#######.#####.###.###.###.#########.#.#####.#####.###.#.#.#.###.###############.#######.#.#######.###.#.###.#
|
||||
#.....#.....#...#...#.#...#.#.....#.....#.....#...#...#.......#...#.........#...#.#.#...#.#.#.#.#.............#.#.....#...#.....#.#.#...#...#
|
||||
#.#############.#####.#.#.#.#.#####.#####.#####.#######.#####.###.#######.#.#.#.#.#.#####.#.#.#.#.#.#.#######.#.#.#.###########.#.#.#.###.###
|
||||
#...............#.....#.#...#.....#.....#.#...#...#.....#...#.....#.#.....#.#.#...#.....#...#.#.#.#.#.#.#.....#.#.#...........#.#.#...#.....#
|
||||
#####.#.#.#.#.###.#####.#########.###.###.#.#.###.#.#####.#.#####.#.#.#####.#.#####.#.#.#.###.#.#.#.#.#.#.###.#.#########.###.#.#.###.#.###.#
|
||||
#.......#.#.#...#.#.......#...#.....#.#...#.#...#...#.....#.....#...#...#...#.....#.#.#.#.#...#...#.#...#.#...#.#.........#.#...#...#.#.#...#
|
||||
#######.###.###.#.#.#.###.#.#.#.#####.#.###.###.#########.#.#.#####.###.###.#####.#.#.###.#.#.###.#.#.###.#.###.#.#########.###.###.###.#.#.#
|
||||
#...........#...#...#.#.....#.#.......#.......#...#.....#.#.#.#.....#.#...#...#...#.#.#...#.#...#.#.#.#.......#.#.#.......................#.#
|
||||
#.#####.#####.#.#.###.#######.#############.#####.#.###.#.#.#.#.#####.###.#####.###.#.#.###.#.###.#.#.#.###.###.#.#.#########.#.#.###.#####.#
|
||||
#.#.........#.....#.#...#...#.............#.#.....#...#...#.#.#.#.......#...#...#.#.#.#.#.#.......#.#.#.#...#...#.#.#.......#.....#.........#
|
||||
#.#####.#.###.#.###.###.###.###########.#.#.#.#.#.###.#.###.#.#.#.#.#######.#.###.#.#.#.#.#.#.#.###.#.#.#.###.###.###.#####.#####.#.#.#####.#
|
||||
#.#.......#...#.......#.#.................#.#.#.#.#...#.#...#.#.#.#.#.....#...#.#...#...#.#.#.#.#.....#.....#.#.#...#...#.#.....#...#.....#.#
|
||||
#.#.###.###.###########.#.#######.#####.###.#.#.#.#.###.#.###.#.###.#.###.#####.#.#######.#.#.#.#.#.###.###.#.#.#.#.###.#.#####.#.#######.#.#
|
||||
#.#.........#.........#.#...#...#.#.....#...#.#...#.......#...#.....#.#...#.....#.#.....#...#.#.#.....#...#.#.#.#.....#.#.....#...#.......#.#
|
||||
#.#.###.#####.#.#####.#.#.#.#.###.#.#####.###.#######.#####.#####.###.#.###.###.#.#.###.#.#.#.#.#######.#.###.#.#.###.#.#.###.###.#.#######.#
|
||||
#.#.......#...#...#...#...#.#.....#...#.....#.#.......#.....#.#...#...#...#.#...#.#...#...#.#.#.......#.#.....#...#...#.#.#.......#.....#...#
|
||||
#.#######.#######.#.#####.#.#########.#.###.#.#.###.###.#####.#.###.#####.#.#.#.#.#######.#.#.#######.#.#######.###.###.###.#####.#####.#####
|
||||
#.......#.........#.#.....#...........#...#.#.#.#.#.#.........#.#...#.....#.#.#.#.#.....#...#.......#.#.....#.....#...#.....#.........#.....#
|
||||
#.#####.###.#######.#.###.#.#.#######.###.#.#.#.#.#.###########.#.###.#####.#.###.#.###.###.#.###.###.#####.#.###.###.#####.#.###.###.#.###.#
|
||||
#.#.#...#...#...#.#...#...........#.......#.#.#...#.#.....#.....#...#...#.........#...#.#...#...#.#...#.#...#.#.....#.....#.#.#.....#.#.#...#
|
||||
#.#.#.###.###.#.#.#####.###.#####.#.#######.#.###.#.#.###.#.#######.###.#.###.#####.#.#.#.#####.###.###.#.###.#.#######.###.#.#.#.###.#.#.#.#
|
||||
#...#.#...#...#.#.......#.....#...#...#...#...#...#.#...#...#...#...#.#...#.........#...#.........#.#.#...#.....#.....#.....#...............#
|
||||
###.#.#####.###.#.###.#########.###.###.#.#.#.#####.###.#####.#.#.###.#####.#########.###########.#.#.#.###.#####.###.#.#####.#####.#.###.#.#
|
||||
#...............#...#.#.........#...#...#.....#.....#...#.....#.#...#.....#...#...#...#.........#.#.#.....#...#...#...#.....#.....#.......#.#
|
||||
#.###.#.#######.#.#.###.#########.###.#####.#.#.#####.#####.#.#####.#.#.###.#.#.#.#.###.#.#####.#.#.#####.#.###.###.#####.#.#.#.#.#########.#
|
||||
#...#.#.#...#...#.#.....#...........#.#...#.#.#.#...#.#.....#.#.....#.#.#...#...#.#.#...#.#...#...#...#...#.#...#.#.......#.#.#.#.....#.....#
|
||||
#.###.#.###.#.#.#####.###############.#.#.###.#.#.#.#.###.#.###.#####.#.#.#######.#.#####.#.#.#######.#.###.#.###.###.#.###.#.#.#.###.#######
|
||||
#.#...#.#...#.#.#...#.......#.........#.#.....#...#.#.#...#.#.......#.#...#.....#.#...#...#.#.#...#...#.....#...#.....#.....#...#...#...#...#
|
||||
#.#.#.#.#.###.###.#.#######.#.#######.#.#######.###.#.#.#####.###.#.#.#####.###.#.###.#.#.#.#.#.#.#.#.#.#######.#.#####.#######.#.#.###.#.#.#
|
||||
#.#.#.#.#...#.....#.....#.....#.......#.#.....#.#.#.....#.....#...#...#.....#...#.#.#...#.#.#.....#.#...#.......#.......#.........#...#...#.#
|
||||
#.#.###.###.#####.#####.#######.#####.#.#.#####.#.#.###.#.#####.#.#####.#.###.###.#.#####.#.#####.#.#.###.###.###.#######.#.###.#####.#####.#
|
||||
#.#...#.....#.........#.......#.#...#.#.#.......#.......#.....#.........#...#.#...#.#...#.#...#...#.#.....#...#...#...#...#.#.....#.#.....#.#
|
||||
#.###.#####.#.###.#####.#####.###.#.###.#.#.#####.#.###.#####.#############.#.#.###.#.#.#.###.#.#.#.#########.#.###.#.#.#.###.###.#.###.###.#
|
||||
#...#.......................#.#...#...#.#...#...#.#.#.#.#.#...#.......#.....#.#.#...#.#.....#.#.#.....#.....#.#.#...#...#.....#.#.#.....#...#
|
||||
###.###.#.###.#.###.#.#.###.#.#.###.#.#.###.#.#.###.#.#.#.#.###.#####.#.#####.#.###.#.#######.#.#####.#.###.#.#.#.#############.#.#######.#.#
|
||||
#.#...#...#.......#...#.#...#...#.#...#...#...#.....#.#...#.....#.#...#.....#.#...#.#.....#...#.......#...#...#.#...#...........#.#.....#.#.#
|
||||
#.###.#####.#####.#####.#########.#.#####.###########.###.#######.#.#####.#.#.###.#.###.###.###########.#.#####.###.#.#.#######.#.#.###.#.#.#
|
||||
#...#.#.......#...#...#...#.......#.....#...#.#.........#.......#.#.#...#.#...#...#.#...#...#.........#.#.....#.#...#.#...#.........#.#...#.#
|
||||
###.#.#.#####.#.###.#.#.#.#.#.#########.###.#.#.#####.#########.#.#.#.#.#######.###.#.###.#######.###.#######.#.#.#.#.#.#.#.###.#.###.#####.#
|
||||
#...#.#.#...#.#...#.#.#.#...#.#.....#...#...#.......#.#.........#.#...#.......#.#...#...#...#.....#.........#.#...#.#.#.#.#.#.....#.........#
|
||||
#.###.#.#.#.#.#####.#.#.#####.#.###.#.###.#####.#####.#.#########.#####.#####.#.#.#.###.###.#.#####.#######.#.#####.#.###.#.###.#.#.#######.#
|
||||
#.#...#.#.#...#.....#.#.#.....#.#.#...#...#.....#.....#.#.........#.........#...#.#.....#.#.#.....#.#...............#.#.......#.#...#.......#
|
||||
#.#.###.#.#####.#####.###.#.###.#.#####.#.#.###.#.#####.###.#####.#########.#####.#.#.###.#.#####.#.#.#.###########.#.#.#.###.#.#.###.###.#.#
|
||||
#...#...#.....#.#.......#.#.#...#.....#.#...#...#.....#.....#...#...........#.....#.#.....#.#...#.#.#.#.#.....#.....#...#...#.#.#.#...#.#.#.#
|
||||
#.###.#######.#.#######.#.#.#.#####.###.#####.###.###.#####.#.#.###.#######.#.###.#######.#.#.#.#.###.#.#.###.#.#####.#####.#.#.#.#.###.#.#.#
|
||||
#.....#.#.....#.#.........#.#...#...#...#...#...#...#.....#.#.#...#.#...#...#...#.......#.#...#.#.....#.#.#...#.#.......#...#.#.#.#.#...#...#
|
||||
#######.#.#####.#.###.#####.###.#.#.#.#####.#.#.#####.#.###.#.###.###.#.#####.#####.#.#.#.#####.#####.#.#.#.#####.#.###.#.#.#.#.#.#.#.#####.#
|
||||
#.......#.#.....#...#...#...#...#.#.#.#.....#.#.....#.#.....#.#.#.....#.......#...#...#...#.....#...#.#.#.#.#.....#.#...#.#.#.#.#.#...#.....#
|
||||
#.#####.#.#.#######.###.#####.###.###.#.###.#.#####.#########.#.#.#.#.#########.#.###.#####.#####.#.###.#.#.#.#####.#.###.#.#.#.#.#####.###.#
|
||||
#...#...#.#.......#...#...#...#.......#.#.#...#...#...........#...#.............#...#.#.....#.....#.....#.#.......#.#.#.....#.#.#.......#...#
|
||||
###.#.###.#.#.#.#.###.###.#.#########.#.#.###.###.#############.#.#########.#.#####.#.#.#####.#######.###.#########.###.#####.#.#.#######.#.#
|
||||
#.#.#.....#...#.#...#...#...#...........#...#.....#...#.....#...#...#...#...#...#...#...#.......#...#.#...#.........#.....#...#.....#...#.#.#
|
||||
#.#.#########.#.#######.#####.#####.#.#.#.#####.#.#.#.#.#.#.#.#####.#.#####.###.#.###.#####.###.#.###.#.###.#.#####.#.#####.#####.#.#.###.#.#
|
||||
#...#.........#.......#.....#.....#.........#...#...#...#.#.#.....#.#.#...#.#.#.#.....#...#...#.#.....#...#.#.#...#.#.#.....#...#.....#...#.#
|
||||
#.#######.###.#####.#.#.###.#####.#.#####.#.#.###.#######.#.###.#.#.#.#.#.#.#.#.#######.#.#####.#.#######.#.#.#.#.###.#.#####.#.#####.#.###.#
|
||||
#.......#.....#...#.#.....#.#...#.#.....#.#...#...#...#.......#.#...#...#.#...#.#.......#.......#.......#.#.....#.#...#.......#...#...#.....#
|
||||
#######.#.###.#.#.###.#####.#.#.#.#####.#.#####.#####.#.#####.#.#.#######.###.#.#.#################.#####.#####.#.#.###########.#.#########.#
|
||||
#.#.............#.....#...#.#.#.......#.#...#.........#.....#.#.#.......#...#.#.#...#...........#...#.....#...#.#.#.#.......#...#.........#.#
|
||||
#.#.#######.#.#.#####.#.#.#.#.###.#####.###.###########.###.#.#.#####.#.###.###.#.#.###.#.###.#.#.###.#####.#.###.#.###.###.###.#########.#.#
|
||||
#.#...#...#.#...#.....#.#...#.#...#.....#.#...#...#...#.#...#.#.#.#...#.#...#...#.#...#.#.#.....#.#...#.#...#.....#...#.#...........#...#...#
|
||||
#.###.#.#.#.#.#.#######.#####.#.###.#####.###.#.#.#.#.#.#.#.###.#.#.###.#.###.###.###.###.#######.#.###.#.#.#########.#.#######.###.#.#.#####
|
||||
#...#...#.#.#...#.....#.......#...#.#...........#...#.#.#.#.#...#.#.#...#.....#.....#...#.....#...#.....#.#.#...#...#.#.........#.#.#.#.....#
|
||||
#.#.#####.#.#.#.#.###.###########.#.#.###############.#.#.###.###.#.#################.#.#.###.#.#######.#.###.#.#.#.#.###.#####.#.#.#.#.###.#
|
||||
#.#.#.....#...#.#.#.#.............#.#.....#.....#...#.#.#...#.....#.#.................#.#.#.#...#.....#.#.....#...#.#...#...#.#.#...#.#.#...#
|
||||
#.#.#.#####.#.###.#.#####.#######.#.#######.###.#.#.#.#####.#.###.#.#.#######.#######.#.#.#.#####.#.#.#.###########.###.###.#.#.#.###.#.###.#
|
||||
#.#.#.#.....#...........#.#.#.....#.#.........#.#.#.#.#...#...#...#.#.#.......#.....#.#.......#...#.#.#.#.........#...#...#...#.#...#.#...#.#
|
||||
#.###.#.#####.#####.#####.#.#.#####.#.#########.#.#.#.#.#.#.#.#.###.#.#.#.#####.###.#.#.#######.###.###.#.#####.###.#####.###.#.###.#.###.###
|
||||
#.#...#.#.........#.#.....#...#...#.....#...#...#...#...#.#.#...#.#.#...#.#.............#.........#.#...#...#.#...#.....#.#...#...#.#...#...#
|
||||
#.#.#####.#######.#.#.#####.###.#########.#.#.###.#.#####.#####.#.#.###.#.###.#########.#.#########.#.#####.#.###.#####.#.#.###.#.#.#######.#
|
||||
#...............#.#.#...#.#.#.......#.....#...#...#.....#.....#...#.#...#...#...#.....#.#.......#.......#.#.....#.....#.#.#...#.#.#.#.......#
|
||||
#.#####.###.#.#.#.###.#.#.#.#######.#.#.#######.#.#.#########.#####.#.#####.#####.###.#########.#.#####.#.#####.###.#.#.#.###.#.#.#.#.#####.#
|
||||
#.....#...#.#...#...#.#.#.#.........#.#.#.....#...#.#.............#.#.#...#.......#.#.......#...#.....#.......#...#...#...#.#...#.#.#.#...#.#
|
||||
###.#.###.#.###.###.#.#.#.#######.###.#.#.###.#.#.#.#.#####.#####.#.#.#.#####.###.#.#####.###.###.###.#.#.#.#####.#.#######.#.#.#.#.#.#.#.#.#
|
||||
#...#.#.#...#...#...#.#.#...#.....#...#...#.#...#.#...#.#...#.....#.#.#...........#.#...#...#...#...#.#.#.#.......#.......#...#...#.#.#.#.#.#
|
||||
#.###.#.#####.#.#.#####.#.###.#####.###.###.#####.#.###.#.###.#####.#.#.#####.###.#.#.#.###.###.#.###.#.#.###.###.###.###.#.###.###.#.#.#.#.#
|
||||
#...#.#.......#.#...#...#.........#...#...........#.....#...........#.#.#...#.#...#.#.....#.........#...#...#.......#.#...#.#.#.#...#.#.#...#
|
||||
###.#.#.###.###.#.#.#.###.#######.###.#####.#####.#.#########.#######.#.#.#.#.###.#.#.#.#.#########.#######.#######.#.#.#.#.#.#.#.###.#.#####
|
||||
#.............#...#.#...#.#...#.#.#.#.......#.....#.#...........#...#.#.#.#.#...#.#...#.#.#.......#...#.......#...#.#...#.....#.#.#...#.#...#
|
||||
#.###.#####.#.###.#.#.#.#.#.#.#.#.#.#########.#####.#.#########.#.#.#.#.#.#.###.#.#####.###.#.###.###.#.#.#####.#.###.#####.###.#.#.#####.#.#
|
||||
#.#.#...#...#...#.#.#.#.#.#.#.#...#...#.......#.....#...#.....#.#.#...#.#.#.#...#.....#.....#.#.......#.....#...#...#.#...#.#...#...#.....#.#
|
||||
#.#.###.#.###.#.#.#.#.#.###.#.#.#####.#.#.#############.#.#####.#.#####.#.#.#.#######.#.#####.#############.#.#####.###.#.#.#.#######.#####.#
|
||||
#.#.#.....#...#.....#.#.....#.#.#.....#.#.......#.....#.#...#...#.#...#.#.#.#.#...#.#.#.....#...............#.....#.....#.#.#...#.....#...#.#
|
||||
#.#.#.#.###########.#.#######.#.###.###.###.###.#.#.###.###.#.###.#.#.#.###.#.#.#.#.#.#####.#####################.#######.#.###.#.#####.#.#.#
|
||||
#.#.....#...........#...#.....#.#...#...#.....#...#...#.....#...#...#.#...#.#.#.#.#.#...#.#...#.......#.........#...#...#.#...#.....#...#...#
|
||||
#.#####.#.###############.#####.#.#.#.#.#.###########.###.#####.#####.###.#.#.#.#.#.###.#.#.###.#####.#.#######.###.#.#.#.#########.#.#.#.#.#
|
||||
#.....#.#.#.........#.....#...#.#.#.........#.......#.#...#.......#...#...#.#.#.#.....#.#...#...#...#...#.....#.....#.#.#.....#...#.#.#...#.#
|
||||
#.###.#.#.#.#######.#.#####.#.#.#.###.###.###.#####.#.#.###.#######.#####.#.#.#.###.###.#.###.#####.#####.###.#########.#####.#.#.#.#.#.#.#.#
|
||||
#...#.#.#...#...#.#...#.....#.#.#.#.....#...#.#...#...#.#...#.......#...#.#.#.#...#.#...#.#...#.....#...#.#...#.........#...#...#.#...#.....#
|
||||
#####.#.#####.#.#.#####.###.#.#.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#######.#.#.#.#.###.#.#.#####.###.#.#.#.#.#.#.###.###.#.#.#.#.#####.#.###.#.#.#
|
||||
#.....#...#...#.#.....#.#...#.#.#...#.#.#.#...#.#.....#.#.#.....#.....#.#...#.#...#.#.......#...#.#.#.#.#.#...#...#.#.....#...#...#.#.....#.#
|
||||
#.#####.#.###.#.#.#.###.#.#####.#####.#.#.#####.#######.#.#####.#.#####.#.###.#.#####.#.#.#.#####.###.#.#.###.###.#.###.#######.#####.#.#.#.#
|
||||
#.#...#.......#...#.#...#.......#.....#.#...#.#.#.......#.....#.#...#.#.#.#...#.....#...#.#.....#.....#.......#...#...#.#.......#.....#.#.#.#
|
||||
#.###.#.#############.###########.#####.###.#.#.#.#########.#.#.###.#.#.###.#.#.###.#####.#####.#.###########.#.#.###.###.#######.#####.#.#.#
|
||||
#...#...#.....#.....#...#.........#.#...#...#...#.#.......#...#.....#.#.....#.....#.....#...#...#.#...........#.#...#.#...#.......#.....#...#
|
||||
###.###.#.###.#.###.###.#####.#####.#.###.###.###.###.#.#.#.#####.#.#.#######.#######.#.###.#.#####.#########.#.###.#.#.###.#.#######.#####.#
|
||||
#...#.......#...#...#...#...#.#.......#...#.....#...#.#.#.#.....#.#.#.#.......#.#.....#...#...#.....#...#.....#...#.#...#...................#
|
||||
#.#.#.#.#########.#.#.###.#.#.#.#######.#.#########.#.#.#.###.#.#.#.#.#.###.#.#.#.#############.#.#.#.#.#########.#.#########.###.#.#.#.###.#
|
||||
#.#.#.#...#...#...#.#...#.#...#.#.....#...#...#...#.#.#.#.....#.#...#.#...#...#.#.................#.#.#.........#.#.........#.#...#...#.#...#
|
||||
#.#.#.#.#.#.#.#.###.###.#.#####.#####.#.###.#.#.#.#.#.#.#.###########.###.#####.#############.#####.#.###.###.#.#.###.#####.#.#.###.###.#.#.#
|
||||
#.#.#.....#.#...#.....#...#...#.....#.#.....#...#...#.#.#...........#.....#.........#.....#...#...#.#...#.....#.#...#...#.#...#.#...#...#.#.#
|
||||
#.#######.#.#####.###.#####.#######.#.#################.#########.###.#####.#######.#.###.#.#.#.#.#.###.#.#.###.###.###.#.#####.#.###.###.#.#
|
||||
#.......#.#.....#.....#...#.......#...#...#...#.........#.....#...#.........#.........#...#.#.#.#.#.#...#.....#...#.....#.......#...#.#...#.#
|
||||
#.#.###.#.#####.#######.#.#.#.#.#.###.#.#.#.###.###.###.#.###.#.###.#######.#.#######.#####.###.#.###.#######.#.#.#############.###.#.#.###.#
|
||||
#.#...#.#...#.#.........#...#.#.#.#.#.#.#...#...#.#.#...#...#.#.....#.......#.#.....#.#...#.....#.#...#.......#.#.....#...................#.#
|
||||
#####.#.###.#.###############.#.#.#.#.#.###.#.###.#.#.#######.#########.#####.#.#.#.###.#.###.#.#.#.###.#####.#.#####.#.#######.#########.#.#
|
||||
#.....#.#...#.........#...#...#.....#.#.#...#...#.#.#.......#.........#...#.#...#.#.....#...#...#.....#.#...#.#...#.........#...#.......#...#
|
||||
#.#####.#.###.#.###.#.###.#.#.#######.#.#.#####.#.#.#######.###.###.#.#.#.#.#.###.#########.###.#####.#.#.###.#.#.#.#####.#.#####.#####.#.#.#
|
||||
#.....#.#.#...#.#.#...#...#.#.#.....#.#...........#.#.....#...#.#...#.#.#.#...#...#.....#...#.......#...#...#.#.#.#.....................#.#.#
|
||||
#.###.#.#.#.###.#.#.###.###.###.###.#.###.###.#####.###.#####.#.#.###.###.#.###.###.###.#.###.#.###.#####.#.#.#.#.###.#.###########.###.#.#.#
|
||||
#...#.#.#.#.#...#...#...#...#...#.............................#.#.#.#...#.#.#.#.......#.#...#.....#.#.....#.....#.#.#.#.#.......#...#...#...#
|
||||
###.#.#.#.###.###.###.#.#.###.###.#####.#.#.###.#.###.#.#.#.#####.#.###.#.#.#.#########.#.#.###.#.#.###########.#.#.#.#.#.#.#####.###.#.###.#
|
||||
#...#.#.#...#.#.....#.#.#.#...#.........#.......#.....#.#.#...#...#...#...#...#...#.....#.......#.#...........#...#...#.#.#...#...#.......#.#
|
||||
#####.#.###.#.#####.#.#.#.#.#######.#####.###.#########.#.###.#.###.#########.#.###.#.#.#.#####.#.#.#########.#.#.#####.###.#.#.#####.#.#.#.#
|
||||
#.....#.#...........................#.....#...#.......#.#...#.#...#.........#.#...#.#...#...#.....#.............#.#...#...#.#.#.....#.#.#.#.#
|
||||
#.#######.###.#.#.#####.#.###########.###.#.#####.###.#.#.###.###.#####.#.#.#.###.#.#.###.#.#######.#.###.#.###.###.#.###.###.#####.#.#.#.#.#
|
||||
#.#.............#.....#.#.....#.....#.....#.....#...#.#.#...#.....#...#.#.#.#.#...#.......#...#...#.#.#...#.#...#.................#.#...#.#.#
|
||||
#.#.###########.#.###.#.###.#.#.###.#.###.#.###.#####.#.###.#######.#.###.#.#.#.#.###.###.###.###.#.#.###.#.#.#.#.###.###.#.#####.#.#.#.###.#
|
||||
#...#.....#.....#.#.#...#...#.#.#.#.#...#.....#.....#.#.#.#.#.......#.....#.#...#...#.......#...#...#.....#.........#.#...#.#.....#.#.#.....#
|
||||
#.#####.#.#.#####.#.#####.#####.#.#.###.###########.#.#.#.#.#.###.#.###############.#.###.#.###.#########.#.#.#.###.#.#.###.#.#####.###.#####
|
||||
#S......#...#...........#.........#.................#.....#.......#...........................#...........#.................#.....#.........#
|
||||
#############################################################################################################################################
|
5
resources/2024/day17.txt
Normal file
5
resources/2024/day17.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Register A: 28066687
|
||||
Register B: 0
|
||||
Register C: 0
|
||||
|
||||
Program: 2,4,1,1,7,5,4,6,0,3,1,4,5,5,3,0
|
3450
resources/2024/day18.txt
Normal file
3450
resources/2024/day18.txt
Normal file
File diff suppressed because it is too large
Load Diff
1691
resources/2024/day22.txt
Normal file
1691
resources/2024/day22.txt
Normal file
File diff suppressed because it is too large
Load Diff
3380
resources/2024/day23.txt
Normal file
3380
resources/2024/day23.txt
Normal file
File diff suppressed because it is too large
Load Diff
313
resources/2024/day24.txt
Normal file
313
resources/2024/day24.txt
Normal file
@@ -0,0 +1,313 @@
|
||||
x00: 1
|
||||
x01: 0
|
||||
x02: 1
|
||||
x03: 1
|
||||
x04: 0
|
||||
x05: 0
|
||||
x06: 1
|
||||
x07: 1
|
||||
x08: 0
|
||||
x09: 1
|
||||
x10: 1
|
||||
x11: 1
|
||||
x12: 1
|
||||
x13: 1
|
||||
x14: 1
|
||||
x15: 0
|
||||
x16: 1
|
||||
x17: 0
|
||||
x18: 1
|
||||
x19: 1
|
||||
x20: 0
|
||||
x21: 0
|
||||
x22: 1
|
||||
x23: 0
|
||||
x24: 1
|
||||
x25: 0
|
||||
x26: 1
|
||||
x27: 0
|
||||
x28: 1
|
||||
x29: 1
|
||||
x30: 0
|
||||
x31: 0
|
||||
x32: 1
|
||||
x33: 1
|
||||
x34: 1
|
||||
x35: 0
|
||||
x36: 1
|
||||
x37: 1
|
||||
x38: 0
|
||||
x39: 0
|
||||
x40: 1
|
||||
x41: 1
|
||||
x42: 0
|
||||
x43: 0
|
||||
x44: 1
|
||||
y00: 1
|
||||
y01: 0
|
||||
y02: 0
|
||||
y03: 1
|
||||
y04: 1
|
||||
y05: 0
|
||||
y06: 0
|
||||
y07: 0
|
||||
y08: 0
|
||||
y09: 0
|
||||
y10: 0
|
||||
y11: 1
|
||||
y12: 0
|
||||
y13: 0
|
||||
y14: 1
|
||||
y15: 1
|
||||
y16: 0
|
||||
y17: 0
|
||||
y18: 1
|
||||
y19: 0
|
||||
y20: 0
|
||||
y21: 0
|
||||
y22: 1
|
||||
y23: 1
|
||||
y24: 0
|
||||
y25: 0
|
||||
y26: 0
|
||||
y27: 1
|
||||
y28: 1
|
||||
y29: 1
|
||||
y30: 0
|
||||
y31: 1
|
||||
y32: 1
|
||||
y33: 0
|
||||
y34: 1
|
||||
y35: 1
|
||||
y36: 0
|
||||
y37: 0
|
||||
y38: 1
|
||||
y39: 1
|
||||
y40: 1
|
||||
y41: 0
|
||||
y42: 0
|
||||
y43: 1
|
||||
y44: 1
|
||||
|
||||
njs AND pvb -> fjh
|
||||
y12 AND x12 -> dcm
|
||||
srv XOR dfc -> z22
|
||||
qwb XOR vmp -> z14
|
||||
njs XOR pvb -> z10
|
||||
cjn OR dfj -> fgc
|
||||
kpp XOR tvh -> z34
|
||||
tbq OR rdf -> frv
|
||||
y40 AND x40 -> drs
|
||||
pqh XOR mmh -> z05
|
||||
x26 XOR y26 -> jkt
|
||||
qqp AND dmw -> kqp
|
||||
qsh OR wfw -> qcr
|
||||
hvw AND qnn -> vgk
|
||||
bkc OR wsq -> ckv
|
||||
ckv XOR bbh -> z03
|
||||
frj XOR hqq -> z02
|
||||
qff OR stw -> wsv
|
||||
qpq XOR vnr -> z30
|
||||
pbk XOR kqc -> z15
|
||||
mvp OR pbv -> dbj
|
||||
x15 AND y15 -> qsh
|
||||
wcs OR cqk -> kpp
|
||||
bmr XOR fgc -> z32
|
||||
y42 XOR x42 -> qjf
|
||||
srv AND dfc -> rng
|
||||
rsq AND nts -> brq
|
||||
fhv AND hjw -> wwg
|
||||
x06 AND y06 -> phw
|
||||
vtf AND gdw -> kpc
|
||||
wvv AND wbf -> qdh
|
||||
y28 AND x28 -> nhs
|
||||
y04 AND x04 -> ttv
|
||||
cts XOR bcd -> qqp
|
||||
mmh AND pqh -> rkt
|
||||
hjw XOR fhv -> z37
|
||||
jdd AND rbm -> z36
|
||||
drt XOR tpt -> z31
|
||||
y20 XOR x20 -> gcf
|
||||
x27 AND y27 -> ptf
|
||||
qnn XOR hvw -> z41
|
||||
x13 AND y13 -> msq
|
||||
cbr XOR hjd -> z07
|
||||
mkv OR hgp -> z45
|
||||
y35 XOR x35 -> spp
|
||||
x08 XOR y08 -> nrk
|
||||
y03 XOR x03 -> bbh
|
||||
fhc OR ggh -> fwt
|
||||
whj AND vrh -> qpj
|
||||
x34 XOR y34 -> tvh
|
||||
y43 AND x43 -> mpm
|
||||
y15 XOR x15 -> pbk
|
||||
x23 XOR y23 -> bcd
|
||||
bwv AND tcd -> sgv
|
||||
bcd AND cts -> jcd
|
||||
ggs OR qmw -> tpt
|
||||
gdm XOR jkm -> z09
|
||||
y38 XOR x38 -> pgm
|
||||
x19 AND y19 -> vmc
|
||||
dtc OR ggg -> kqc
|
||||
hqq AND frj -> bkc
|
||||
smv OR wwg -> bhh
|
||||
y17 AND x17 -> tfq
|
||||
x14 AND y14 -> dtc
|
||||
y39 AND x39 -> ggh
|
||||
jmh AND cjc -> gfp
|
||||
mgj XOR wsv -> z12
|
||||
ftd AND wcw -> hjm
|
||||
y19 XOR x19 -> whj
|
||||
nrk AND ksd -> vwf
|
||||
fgq AND spp -> drp
|
||||
rsq XOR nts -> z18
|
||||
y10 XOR x10 -> njs
|
||||
frv XOR qdb -> z04
|
||||
wbk OR fcv -> fgq
|
||||
whj XOR vrh -> z19
|
||||
tvh AND kpp -> wbk
|
||||
y39 XOR x39 -> pwt
|
||||
scg OR gkj -> grv
|
||||
dfn XOR qcr -> pbv
|
||||
x27 XOR y27 -> ftd
|
||||
svg OR tfq -> rsq
|
||||
fkd XOR fwt -> z40
|
||||
x07 AND y07 -> pdq
|
||||
y13 XOR x13 -> hnt
|
||||
grv XOR vpm -> z21
|
||||
y02 XOR x02 -> frj
|
||||
jkt XOR dbp -> z26
|
||||
wdr OR jcd -> z23
|
||||
x21 AND y21 -> wns
|
||||
y08 AND x08 -> btn
|
||||
qqp XOR dmw -> z24
|
||||
x01 AND y01 -> wqt
|
||||
frw AND hdp -> hgq
|
||||
frk AND wpk -> hgp
|
||||
x07 XOR y07 -> cbr
|
||||
x29 AND y29 -> jgm
|
||||
sgv OR wqt -> hqq
|
||||
tpt AND drt -> dfj
|
||||
sdn OR rkt -> kqk
|
||||
frv AND qdb -> vjj
|
||||
fjh OR thp -> ncw
|
||||
y26 AND x26 -> vvr
|
||||
x25 AND y25 -> kcs
|
||||
ftd XOR wcw -> z27
|
||||
tcd XOR bwv -> z01
|
||||
brk XOR kqk -> z06
|
||||
x10 AND y10 -> thp
|
||||
frw XOR hdp -> z25
|
||||
pgm AND bhh -> hsh
|
||||
x24 XOR y24 -> dmw
|
||||
vmc OR qpj -> bkv
|
||||
x44 AND y44 -> mkv
|
||||
knh OR vgk -> rps
|
||||
dfn AND qcr -> mvp
|
||||
tqj OR rng -> cts
|
||||
tbb OR wns -> srv
|
||||
msq OR pjj -> vmp
|
||||
drs OR ghn -> hvw
|
||||
hsh OR rrb -> rms
|
||||
dbj XOR bgt -> z17
|
||||
mpm OR kpc -> frk
|
||||
bgt AND dbj -> svg
|
||||
x40 XOR y40 -> fkd
|
||||
x16 AND y16 -> z16
|
||||
cbr AND hjd -> dvs
|
||||
fsb OR drv -> gdw
|
||||
cjc XOR jmh -> z29
|
||||
pdq OR dvs -> ksd
|
||||
rpw OR fbq -> fhv
|
||||
y05 XOR x05 -> pqh
|
||||
x30 AND y30 -> ggs
|
||||
bmb OR drp -> jdd
|
||||
hnt XOR fbm -> z13
|
||||
y42 AND x42 -> fsb
|
||||
qpq AND vnr -> qmw
|
||||
x11 XOR y11 -> qff
|
||||
gcf AND bkv -> gkj
|
||||
wvv XOR wbf -> z28
|
||||
x05 AND y05 -> sdn
|
||||
pqp OR phw -> hjd
|
||||
jdd XOR rbm -> fbq
|
||||
njt OR kqp -> frw
|
||||
y00 XOR x00 -> z00
|
||||
y31 AND x31 -> cjn
|
||||
x32 XOR y32 -> bmr
|
||||
x34 AND y34 -> fcv
|
||||
y24 AND x24 -> njt
|
||||
y06 XOR x06 -> brk
|
||||
x12 XOR y12 -> mgj
|
||||
ckv AND bbh -> tbq
|
||||
rps XOR qjf -> z42
|
||||
x33 AND y33 -> cqk
|
||||
y09 AND x09 -> nhk
|
||||
y33 XOR x33 -> mbp
|
||||
x04 XOR y04 -> qdb
|
||||
x22 AND y22 -> tqj
|
||||
y20 AND x20 -> scg
|
||||
y01 XOR x01 -> tcd
|
||||
fgc AND bmr -> shp
|
||||
mbp XOR pnw -> z33
|
||||
frk XOR wpk -> z44
|
||||
y43 XOR x43 -> vtf
|
||||
x37 XOR y37 -> hjw
|
||||
y03 AND x03 -> rdf
|
||||
rms XOR pwt -> z39
|
||||
bhh XOR pgm -> z38
|
||||
spp XOR fgq -> z35
|
||||
y22 XOR x22 -> dfc
|
||||
qjf AND rps -> drv
|
||||
kcs OR hgq -> dbp
|
||||
y29 XOR x29 -> cjc
|
||||
x25 XOR y25 -> hdp
|
||||
hbq OR dcm -> fbm
|
||||
brk AND kqk -> pqp
|
||||
qwb AND vmp -> ggg
|
||||
gpb OR shp -> pnw
|
||||
y02 AND x02 -> wsq
|
||||
ptf OR hjm -> wvv
|
||||
x18 XOR y18 -> nts
|
||||
x23 AND y23 -> wdr
|
||||
x09 XOR y09 -> jkm
|
||||
x36 AND y36 -> rpw
|
||||
x32 AND y32 -> gpb
|
||||
mbp AND pnw -> wcs
|
||||
jgm OR gfp -> qpq
|
||||
x11 AND y11 -> qnw
|
||||
bkv XOR gcf -> z20
|
||||
nhk OR ftf -> pvb
|
||||
gdw XOR vtf -> z43
|
||||
vjj OR ttv -> mmh
|
||||
x41 AND y41 -> knh
|
||||
ncw XOR qnw -> z11
|
||||
y28 XOR x28 -> wbf
|
||||
y36 XOR x36 -> rbm
|
||||
mgj AND wsv -> hbq
|
||||
hnt AND fbm -> pjj
|
||||
brq OR bfd -> vrh
|
||||
x17 XOR y17 -> bgt
|
||||
ksd XOR nrk -> z08
|
||||
x38 AND y38 -> rrb
|
||||
fwt AND fkd -> ghn
|
||||
ncw AND qnw -> stw
|
||||
x18 AND y18 -> bfd
|
||||
y00 AND x00 -> bwv
|
||||
gdm AND jkm -> ftf
|
||||
rms AND pwt -> fhc
|
||||
x16 XOR y16 -> dfn
|
||||
y37 AND x37 -> smv
|
||||
x35 AND y35 -> bmb
|
||||
y30 XOR x30 -> vnr
|
||||
jkt AND dbp -> dbt
|
||||
y41 XOR x41 -> qnn
|
||||
x31 XOR y31 -> drt
|
||||
qdh OR nhs -> jmh
|
||||
vwf OR btn -> gdm
|
||||
y44 XOR x44 -> wpk
|
||||
x14 XOR y14 -> qwb
|
||||
x21 XOR y21 -> vpm
|
||||
pbk AND kqc -> wfw
|
||||
vvr OR dbt -> wcw
|
||||
grv AND vpm -> tbb
|
3999
resources/2024/day25.txt
Normal file
3999
resources/2024/day25.txt
Normal file
File diff suppressed because it is too large
Load Diff
9
run.py
9
run.py
@@ -86,13 +86,20 @@ def generate_commands_z80(problem: Problem, flags:Optional[list[str]]=None):
|
||||
run_compile_command(f"cat {preamble_location} {problem.build_location} > {problem.build_location + "0"}", shell=True)
|
||||
|
||||
run_run_command(f"echo q | {simulator_location} -x{problem.build_location}0", shell=True)
|
||||
|
||||
|
||||
def generate_commands_c(problem: Problem, flags):
|
||||
|
||||
run_compile_command(["gcc", problem.source_location, "-o", problem.build_location])
|
||||
run_run_command(" ".join(["cat", problem.resource_location, "|", "./" + problem.build_location]), shell=True)
|
||||
|
||||
|
||||
languages = {
|
||||
"pladcl": Language("pladcl", "pdl", generate_commands_pladcl, build_extension="dc"),
|
||||
"pascal": Language("pascal", "pas", generate_commands_pascal),
|
||||
"python": Language("python", "py", lambda problem, flags: run_run_command(["python3", problem.source_location] + (flags if flags else []))),
|
||||
"z80": Language("z80", "z80", generate_commands_z80, build_extension="bin")
|
||||
"z80": Language("z80", "z80", generate_commands_z80, build_extension="bin"),
|
||||
"c": Language("c", "c", generate_commands_c, build_extension="out")
|
||||
}
|
||||
|
||||
|
||||
|
146
src/c/2024/day18/part1.c
Normal file
146
src/c/2024/day18/part1.c
Normal file
@@ -0,0 +1,146 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BOARD_SIZE 71
|
||||
#define NUM_BYTES 1024
|
||||
|
||||
#define WALL 10005
|
||||
|
||||
#define IN_BOUND(x, y) (x < BOARD_SIZE && x >= 0 && y < BOARD_SIZE && y >= 0)
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
|
||||
struct coordinate {
|
||||
|
||||
int x, y;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct coordinate queue[10000];
|
||||
int queue_len;
|
||||
int queue_start;
|
||||
|
||||
char map[BOARD_SIZE][BOARD_SIZE];
|
||||
int values[BOARD_SIZE][BOARD_SIZE];
|
||||
|
||||
|
||||
int queue_pop(struct coordinate *coord) {
|
||||
|
||||
if (queue_len == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(coord, &queue[queue_start], sizeof(struct coordinate));
|
||||
|
||||
queue_start++;
|
||||
queue_len--;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void queue_push(struct coordinate *coord) {
|
||||
|
||||
|
||||
//printf("%d, %da\n", coord->x, coord->y);
|
||||
|
||||
memcpy(&queue[queue_start + queue_len], coord, sizeof(struct coordinate));
|
||||
queue_len++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void check_and_push(struct coordinate *coord, int depth) {
|
||||
|
||||
//printf("%d\n", depth);
|
||||
|
||||
if (!IN_BOUND(coord->x, coord->y) || values[coord->x][coord->y] == WALL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (values[coord->x][coord->y] == 100000) {
|
||||
//printf("%d\n", depth);
|
||||
values[coord->x][coord->y] = depth + 1;
|
||||
queue_push(coord);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int dfs(struct coordinate coord) {
|
||||
|
||||
queue_push(&coord);
|
||||
values[coord.x][coord.y] = 0;
|
||||
|
||||
while (!queue_pop(&coord)) {
|
||||
|
||||
int value = values[coord.x][coord.y];
|
||||
|
||||
//printf("%d, %d: %d\n", coord.x, coord.y, values[coord.x][coord.y]);
|
||||
|
||||
if (coord.x == BOARD_SIZE - 1 && coord.y == BOARD_SIZE - 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
coord.x++;
|
||||
check_and_push(&coord, value);
|
||||
coord.x -= 2;
|
||||
check_and_push(&coord, value);
|
||||
coord.x++;
|
||||
|
||||
coord.y++;
|
||||
check_and_push(&coord, value);
|
||||
coord.y -= 2;
|
||||
check_and_push(&coord, value);
|
||||
coord.y++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return values[BOARD_SIZE - 1][BOARD_SIZE - 1];
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
char *line_buf = NULL;
|
||||
size_t buffer_size = 100;
|
||||
|
||||
for (int i = 0; i < BOARD_SIZE; i++) {
|
||||
for (int j = 0; j < BOARD_SIZE; j++) {
|
||||
map[i][j] = '.';
|
||||
values[i][j] = 100000;
|
||||
}
|
||||
}
|
||||
|
||||
struct coordinate coords[10000];
|
||||
int num_cords = 0;
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 0) {
|
||||
|
||||
sscanf(line_buf, "%d,%d\n", &coords[num_cords].x, &coords[num_cords].y);
|
||||
num_cords++;
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_BYTES; i++) {
|
||||
|
||||
struct coordinate coord = coords[i];
|
||||
|
||||
values[coords[i].x][coords[i].y] = WALL;
|
||||
|
||||
//printf("%d, %dwa\n", coords[i].x, coords[i].y);
|
||||
//values[coord.x][coord.y] = 10000;
|
||||
|
||||
}
|
||||
|
||||
struct coordinate start;
|
||||
|
||||
start.x = 0;
|
||||
start.y = 0;
|
||||
|
||||
printf("res: %d\n", dfs(start));
|
||||
}
|
170
src/c/2024/day18/part2.c
Normal file
170
src/c/2024/day18/part2.c
Normal file
@@ -0,0 +1,170 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BOARD_SIZE 71
|
||||
|
||||
#define WALL 10005
|
||||
|
||||
#define IN_BOUND(x, y) (x < BOARD_SIZE && x >= 0 && y < BOARD_SIZE && y >= 0)
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
|
||||
struct coordinate {
|
||||
|
||||
int x, y;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct coordinate queue[10000];
|
||||
int queue_len;
|
||||
int queue_start;
|
||||
|
||||
char map[BOARD_SIZE][BOARD_SIZE];
|
||||
int values[BOARD_SIZE][BOARD_SIZE];
|
||||
|
||||
|
||||
void queue_empty() {
|
||||
|
||||
queue_start = 0;
|
||||
queue_len = 0;
|
||||
|
||||
}
|
||||
|
||||
int queue_pop(struct coordinate *coord) {
|
||||
|
||||
if (queue_len == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(coord, &queue[queue_start], sizeof(struct coordinate));
|
||||
|
||||
queue_start++;
|
||||
queue_len--;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void queue_push(struct coordinate *coord) {
|
||||
|
||||
|
||||
//printf("%d, %da\n", coord->x, coord->y);
|
||||
|
||||
memcpy(&queue[queue_start + queue_len], coord, sizeof(struct coordinate));
|
||||
queue_len++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void check_and_push(struct coordinate *coord, int depth) {
|
||||
|
||||
//printf("%d\n", depth);
|
||||
|
||||
if (!IN_BOUND(coord->x, coord->y) || values[coord->x][coord->y] == WALL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (values[coord->x][coord->y] == 100000) {
|
||||
//printf("%d\n", depth);
|
||||
values[coord->x][coord->y] = depth + 1;
|
||||
queue_push(coord);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int dfs(struct coordinate coord) {
|
||||
|
||||
queue_push(&coord);
|
||||
values[coord.x][coord.y] = 0;
|
||||
|
||||
while (!queue_pop(&coord)) {
|
||||
|
||||
int value = values[coord.x][coord.y];
|
||||
|
||||
//printf("%d, %d: %d\n", coord.x, coord.y, values[coord.x][coord.y]);
|
||||
|
||||
if (coord.x == BOARD_SIZE - 1 && coord.y == BOARD_SIZE - 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
coord.x++;
|
||||
check_and_push(&coord, value);
|
||||
coord.x -= 2;
|
||||
check_and_push(&coord, value);
|
||||
coord.x++;
|
||||
|
||||
coord.y++;
|
||||
check_and_push(&coord, value);
|
||||
coord.y -= 2;
|
||||
check_and_push(&coord, value);
|
||||
coord.y++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return values[BOARD_SIZE - 1][BOARD_SIZE - 1];
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
char *line_buf = NULL;
|
||||
size_t buffer_size = 100;
|
||||
|
||||
for (int i = 0; i < BOARD_SIZE; i++) {
|
||||
for (int j = 0; j < BOARD_SIZE; j++) {
|
||||
map[i][j] = '.';
|
||||
values[i][j] = 100000;
|
||||
}
|
||||
}
|
||||
|
||||
struct coordinate coords[10000];
|
||||
int num_cords = 0;
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 0) {
|
||||
|
||||
sscanf(line_buf, "%d,%d\n", &coords[num_cords].x, &coords[num_cords].y);
|
||||
num_cords++;
|
||||
|
||||
}
|
||||
|
||||
for (int c = 0; c < num_cords; c++) {
|
||||
|
||||
for (int i = 0; i < BOARD_SIZE; i++) {
|
||||
for (int j = 0; j < BOARD_SIZE; j++) {
|
||||
values[i][j] = 100000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
|
||||
struct coordinate coord = coords[i];
|
||||
|
||||
values[coords[i].x][coords[i].y] = WALL;
|
||||
|
||||
}
|
||||
|
||||
struct coordinate start;
|
||||
|
||||
start.x = 0;
|
||||
start.y = 0;
|
||||
|
||||
int res = dfs(start);
|
||||
|
||||
printf("%d: %d\n", c, res);
|
||||
|
||||
if (res == 100000) {
|
||||
printf("res: %d,%d\n", coords[c - 1].x, coords[c - 1].y);
|
||||
break;
|
||||
}
|
||||
|
||||
queue_empty();
|
||||
//printf("res: %d\n", dfs(start));
|
||||
|
||||
}
|
||||
}
|
235
src/c/2024/day24/part1.c
Normal file
235
src/c/2024/day24/part1.c
Normal file
@@ -0,0 +1,235 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int numeric_id(char* string) {
|
||||
|
||||
return string[0] * 65536 + string[1] * 256 + string[2];
|
||||
|
||||
}
|
||||
|
||||
int number(char* string) {
|
||||
|
||||
return (string[1] - 48) * 10 + string[2] - 48;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int number_from_id(int id) {
|
||||
|
||||
return ((id / 256 % 256) - 48) * 10 + (id % 256 - 48);
|
||||
|
||||
}
|
||||
|
||||
int operator_to_id(char* str){
|
||||
|
||||
if (strcmp(str, "AND") == 0) {
|
||||
return 1;
|
||||
} else if (strcmp(str, "OR") == 0) {
|
||||
return 2;
|
||||
} else if (strcmp(str, "XOR") == 0) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
printf("Bad operator: %s\n", str);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
int zvalue_to_id(int znum) {
|
||||
|
||||
return 'z' * 65536 + (znum / 10 + 48) * 256 + znum % 10 + 48;
|
||||
|
||||
}
|
||||
|
||||
int apply_operator(int v1, int op, int v2) {
|
||||
|
||||
if (op == 1) {
|
||||
|
||||
return v1 & v2;
|
||||
|
||||
} else if (op == 2) {
|
||||
|
||||
return v1 | v2;
|
||||
|
||||
} else if (op == 3) {
|
||||
|
||||
return v1 ^ v2;
|
||||
|
||||
}
|
||||
|
||||
printf("Bad operator id: %d\n", op);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
struct rule {
|
||||
int op1;
|
||||
int op2;
|
||||
int operator;
|
||||
int result;
|
||||
};
|
||||
|
||||
struct value {
|
||||
int key;
|
||||
int value;
|
||||
};
|
||||
|
||||
|
||||
struct value values[1000];
|
||||
struct rule rules[1000];
|
||||
|
||||
int num_values = 0;
|
||||
int num_rules = 0;
|
||||
|
||||
|
||||
int add_value(int key, int value) {
|
||||
|
||||
values[num_values].value = value;
|
||||
values[num_values].key = key;
|
||||
|
||||
num_values++;
|
||||
|
||||
}
|
||||
|
||||
int get_value(int id) {
|
||||
|
||||
for (int i = 0; i < num_values; i++) {
|
||||
|
||||
if (values[i].key == id) {
|
||||
return values[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
int max_z = 0;
|
||||
|
||||
|
||||
// reading junk
|
||||
size_t buffer_size = 100;
|
||||
char *line_buf = NULL;
|
||||
char buffer[buffer_size];
|
||||
char op1[buffer_size];
|
||||
char op2[buffer_size];
|
||||
char operator[buffer_size];
|
||||
char end_goal[buffer_size];
|
||||
|
||||
int value;
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 1) {
|
||||
|
||||
sscanf(line_buf, "%3s: %d\n", buffer, &value);
|
||||
|
||||
add_value(numeric_id(buffer), value);
|
||||
}
|
||||
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 0) {
|
||||
sscanf(line_buf, "%3s %3s %3s -> %3s", op1, operator, op2, end_goal);
|
||||
|
||||
if (end_goal[0] == 'z') {
|
||||
if (number(end_goal) > max_z) {
|
||||
max_z = number(end_goal);
|
||||
}
|
||||
}
|
||||
|
||||
rules[num_rules].op1 = numeric_id(op1);
|
||||
rules[num_rules].op2 = numeric_id(op2);
|
||||
rules[num_rules].operator = operator_to_id(operator);
|
||||
rules[num_rules].result = numeric_id(end_goal);
|
||||
|
||||
num_rules++;
|
||||
}
|
||||
|
||||
int found_zs[max_z];
|
||||
max_z++;
|
||||
int rule_applied[num_rules];
|
||||
|
||||
for (int i = 0; i < num_rules; i++) {
|
||||
|
||||
rule_applied[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < max_z; i++) {
|
||||
|
||||
found_zs[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
printf("Read %d values and %d rules, trying to find %d zs\n", num_values, num_rules, max_z);
|
||||
|
||||
for (;;) {
|
||||
|
||||
for (int i = 0; i < num_rules; i++) {
|
||||
|
||||
int v1, v2;
|
||||
|
||||
if (rule_applied[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((v1 = get_value(rules[i].op1)) >= 0 && (v2 = get_value(rules[i].op2)) >= 0) {
|
||||
|
||||
int res = apply_operator(v1, rules[i].operator, v2);
|
||||
|
||||
//printf("%d: %d\n", rules[i].result, res);
|
||||
|
||||
add_value(rules[i].result, res);
|
||||
|
||||
if (rules[i].result / 65536 == 'z') {
|
||||
|
||||
found_zs[number_from_id(rules[i].result)] = 1;
|
||||
printf("Found z%d\n", number_from_id(rules[i].result));
|
||||
//printf("%x", rules[i].result);
|
||||
|
||||
}
|
||||
|
||||
rule_applied[i] = 1;
|
||||
|
||||
}
|
||||
|
||||
//printf("%d, %d\n", v1, v2);
|
||||
|
||||
}
|
||||
|
||||
int finished = 1;
|
||||
for (int i = 0; i < max_z; i++) {
|
||||
|
||||
if (found_zs[i] == 0) {
|
||||
|
||||
finished = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (finished) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long out = 0;
|
||||
for (int i = max_z - 1; i >= 0; i--) {
|
||||
|
||||
out *= 2;
|
||||
int n = get_value(zvalue_to_id(i));
|
||||
printf("%d", n);
|
||||
out += n;
|
||||
|
||||
//printf("%x\n", zvalue_to_id(i));
|
||||
}
|
||||
|
||||
printf("\nres: %ld\n", out);
|
||||
}
|
235
src/c/2024/day24/part2.c
Normal file
235
src/c/2024/day24/part2.c
Normal file
@@ -0,0 +1,235 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int numeric_id(char* string) {
|
||||
|
||||
return string[0] * 65536 + string[1] * 256 + string[2];
|
||||
|
||||
}
|
||||
|
||||
int number(char* string) {
|
||||
|
||||
return (string[1] - 48) * 10 + string[2] - 48;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int number_from_id(int id) {
|
||||
|
||||
return ((id / 256 % 256) - 48) * 10 + (id % 256 - 48);
|
||||
|
||||
}
|
||||
|
||||
int operator_to_id(char* str){
|
||||
|
||||
if (strcmp(str, "AND") == 0) {
|
||||
return 1;
|
||||
} else if (strcmp(str, "OR") == 0) {
|
||||
return 2;
|
||||
} else if (strcmp(str, "XOR") == 0) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
printf("Bad operator: %s\n", str);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
int zvalue_to_id(int znum) {
|
||||
|
||||
return 'z' * 65536 + (znum / 10 + 48) * 256 + znum % 10 + 48;
|
||||
|
||||
}
|
||||
|
||||
int apply_operator(int v1, int op, int v2) {
|
||||
|
||||
if (op == 1) {
|
||||
|
||||
return v1 & v2;
|
||||
|
||||
} else if (op == 2) {
|
||||
|
||||
return v1 | v2;
|
||||
|
||||
} else if (op == 3) {
|
||||
|
||||
return v1 ^ v2;
|
||||
|
||||
}
|
||||
|
||||
printf("Bad operator id: %d\n", op);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
struct rule {
|
||||
int op1;
|
||||
int op2;
|
||||
int operator;
|
||||
int result;
|
||||
};
|
||||
|
||||
struct value {
|
||||
int key;
|
||||
int value;
|
||||
};
|
||||
|
||||
|
||||
struct value values[1000];
|
||||
struct rule rules[1000];
|
||||
|
||||
int num_values = 0;
|
||||
int num_rules = 0;
|
||||
|
||||
|
||||
int add_value(int key, int value) {
|
||||
|
||||
values[num_values].value = value;
|
||||
values[num_values].key = key;
|
||||
|
||||
num_values++;
|
||||
|
||||
}
|
||||
|
||||
int get_value(int id) {
|
||||
|
||||
for (int i = 0; i < num_values; i++) {
|
||||
|
||||
if (values[i].key == id) {
|
||||
return values[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
int max_z = 0;
|
||||
|
||||
|
||||
// reading junk
|
||||
size_t buffer_size = 100;
|
||||
char *line_buf = NULL;
|
||||
char buffer[buffer_size];
|
||||
char op1[buffer_size];
|
||||
char op2[buffer_size];
|
||||
char operator[buffer_size];
|
||||
char end_goal[buffer_size];
|
||||
|
||||
int value;
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 1) {
|
||||
|
||||
sscanf(line_buf, "%3s: %d\n", buffer, &value);
|
||||
|
||||
add_value(numeric_id(buffer), value);
|
||||
}
|
||||
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 0) {
|
||||
sscanf(line_buf, "%3s %3s %3s -> %3s", op1, operator, op2, end_goal);
|
||||
|
||||
if (end_goal[0] == 'z') {
|
||||
if (number(end_goal) > max_z) {
|
||||
max_z = number(end_goal);
|
||||
}
|
||||
}
|
||||
|
||||
rules[num_rules].op1 = numeric_id(op1);
|
||||
rules[num_rules].op2 = numeric_id(op2);
|
||||
rules[num_rules].operator = operator_to_id(operator);
|
||||
rules[num_rules].result = numeric_id(end_goal);
|
||||
|
||||
num_rules++;
|
||||
}
|
||||
|
||||
int found_zs[max_z];
|
||||
max_z++;
|
||||
int rule_applied[num_rules];
|
||||
|
||||
for (int i = 0; i < num_rules; i++) {
|
||||
|
||||
rule_applied[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < max_z; i++) {
|
||||
|
||||
found_zs[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
printf("Read %d values and %d rules, trying to find %d zs\n", num_values, num_rules, max_z);
|
||||
|
||||
for (;;) {
|
||||
|
||||
for (int i = 0; i < num_rules; i++) {
|
||||
|
||||
int v1, v2;
|
||||
|
||||
if (rule_applied[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((v1 = get_value(rules[i].op1)) >= 0 && (v2 = get_value(rules[i].op2)) >= 0) {
|
||||
|
||||
int res = apply_operator(v1, rules[i].operator, v2);
|
||||
|
||||
//printf("%d: %d\n", rules[i].result, res);
|
||||
|
||||
add_value(rules[i].result, res);
|
||||
|
||||
if (rules[i].result / 65536 == 'z') {
|
||||
|
||||
found_zs[number_from_id(rules[i].result)] = 1;
|
||||
printf("Found z%d\n", number_from_id(rules[i].result));
|
||||
//printf("%x", rules[i].result);
|
||||
|
||||
}
|
||||
|
||||
rule_applied[i] = 1;
|
||||
|
||||
}
|
||||
|
||||
//printf("%d, %d\n", v1, v2);
|
||||
|
||||
}
|
||||
|
||||
int finished = 1;
|
||||
for (int i = 0; i < max_z; i++) {
|
||||
|
||||
if (found_zs[i] == 0) {
|
||||
|
||||
finished = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (finished) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long out = 0;
|
||||
for (int i = max_z - 1; i >= 0; i--) {
|
||||
|
||||
out *= 2;
|
||||
int n = get_value(zvalue_to_id(i));
|
||||
printf("%d", n);
|
||||
out += n;
|
||||
|
||||
//printf("%x\n", zvalue_to_id(i));
|
||||
}
|
||||
|
||||
printf("\nres: %ld\n", out);
|
||||
}
|
83
src/c/2024/day25/part1.c
Normal file
83
src/c/2024/day25/part1.c
Normal file
@@ -0,0 +1,83 @@
|
||||
#include <stdio.h>
|
||||
|
||||
struct lockkey {
|
||||
|
||||
int positions[5];
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
|
||||
|
||||
|
||||
size_t buffer_size = 100;
|
||||
char* line_buf = NULL;
|
||||
|
||||
struct lockkey locks[1000];
|
||||
struct lockkey keys[1000];
|
||||
|
||||
int num_locks, num_keys;
|
||||
|
||||
int is_key;
|
||||
|
||||
while (getline(&line_buf, &buffer_size, stdin) > 0) {
|
||||
|
||||
struct lockkey *current;
|
||||
|
||||
if (line_buf[0] == '.') {
|
||||
current = &keys[num_keys];
|
||||
num_keys++;
|
||||
printf("Read key: ");
|
||||
} else {
|
||||
current = &locks[num_locks];
|
||||
num_locks++;
|
||||
printf("Read lock: ");
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
current->positions[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
getline(&line_buf, &buffer_size, stdin);
|
||||
for (int j = 0; j < 5; j++) {
|
||||
if (line_buf[j] == '#') {
|
||||
current->positions[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("%d,%d,%d,%d,%d\n", current->positions[0], current->positions[1], current->positions[2], current->positions[3], current->positions[4]);
|
||||
|
||||
getline(&line_buf, &buffer_size, stdin);
|
||||
getline(&line_buf, &buffer_size, stdin);
|
||||
}
|
||||
|
||||
long out = 0;
|
||||
for (int i = 0; i < num_locks; i++) {
|
||||
for (int j = 0; j < num_keys; j++) {
|
||||
|
||||
int ok = 1;
|
||||
for (int k = 0; k < 5; k++) {
|
||||
|
||||
if (locks[i].positions[k] + keys[j].positions[k] > 5) {
|
||||
ok = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
out++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("res: %ld\n", out);
|
||||
|
||||
}
|
243
src/pladcl/2024/day16/part1.pdl
Normal file
243
src/pladcl/2024/day16/part1.pdl
Normal file
@@ -0,0 +1,243 @@
|
||||
interrupt program_start
|
||||
|
||||
`1 0:X` # 1 + heap size
|
||||
# X is heap
|
||||
|
||||
# Y is values of heap
|
||||
|
||||
|
||||
end
|
||||
|
||||
state start
|
||||
|
||||
if `ln` == 'E' then
|
||||
`lisE`
|
||||
end
|
||||
if `ln` == 'S' then
|
||||
# set for iterate heap
|
||||
array_set('I', `li`, '.')
|
||||
`lisS`
|
||||
end
|
||||
|
||||
if `lw` == 0 and `ln` == 10 then
|
||||
`li1+sw`
|
||||
`0lw-0:V` # up
|
||||
`1 1:V` # right
|
||||
`lw2:V` # down
|
||||
`_1 3:V` # left
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
interrupt program_end
|
||||
|
||||
`[starting]n10an`
|
||||
|
||||
# 0123 = NESW
|
||||
`1` # start facing east
|
||||
`lS10*+` # add in start position
|
||||
|
||||
`sv` # value for heap
|
||||
`0sp` # priority starts at 0
|
||||
heap_add() # add into heap
|
||||
|
||||
while iterate_heap() != 1 do
|
||||
|
||||
end
|
||||
|
||||
`lpn`
|
||||
|
||||
end
|
||||
|
||||
function iterate_heap
|
||||
|
||||
heap_pop()
|
||||
|
||||
`lv`
|
||||
`10~`
|
||||
`sdsi` # get direction and index
|
||||
|
||||
# if we've already been here
|
||||
if array_get('L', `lv`) == 1 then
|
||||
return 0
|
||||
end
|
||||
# finish
|
||||
array_set('L', `lv`, 1)
|
||||
|
||||
|
||||
|
||||
|
||||
`lin[ ]nlpn10an`
|
||||
|
||||
|
||||
if `li` == `lE` then
|
||||
#`[done]n`
|
||||
return 1
|
||||
end
|
||||
|
||||
if `li;I` != '.' then
|
||||
#`[bad]n10an`
|
||||
return 0
|
||||
end
|
||||
|
||||
# inc cost
|
||||
`lp1+sp`
|
||||
|
||||
# forward
|
||||
`li`
|
||||
`ld;V+` # add in vector
|
||||
`10*ld+sv` # and direction
|
||||
heap_add()
|
||||
|
||||
# inc cost again
|
||||
`lp1000+sp`
|
||||
|
||||
# right
|
||||
`ld1+4%sd`
|
||||
|
||||
`li`
|
||||
`ld;V+` # add in vector
|
||||
`10*ld+sv` # and direction
|
||||
heap_add()
|
||||
|
||||
# left
|
||||
`ld2+4%sd`
|
||||
|
||||
`li`
|
||||
`ld;V+` # add in vector
|
||||
`10*ld+sv` # and direction
|
||||
heap_add()
|
||||
|
||||
0
|
||||
|
||||
end
|
||||
|
||||
function calculate_vecs
|
||||
# 0 = forward
|
||||
# 1 = right
|
||||
# 2 = down
|
||||
# 3 = left
|
||||
|
||||
if `ld` == 0 then
|
||||
`lw-`
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function heap_add
|
||||
|
||||
# priority in p, value in v
|
||||
|
||||
array_set('X', `0;X`, `lp`)
|
||||
array_set('Y', `0;X`, `lv`)
|
||||
|
||||
# up heap
|
||||
`0;X`
|
||||
up_heap()
|
||||
|
||||
# inc heap size
|
||||
#`[wow]n10an`
|
||||
array_set('X', 0, `0;X1+`)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function heap_pop
|
||||
|
||||
if `0;X` == 1 then
|
||||
`[nothing to pop]n10an`
|
||||
`5Q`
|
||||
end
|
||||
|
||||
# returns priority in p, value in v
|
||||
|
||||
# get return values
|
||||
array_get('X', 1)
|
||||
`sp`
|
||||
array_get('Y', 1)
|
||||
`sv`
|
||||
|
||||
# dec heap size
|
||||
array_set('X', 0, `0;X1-`)
|
||||
|
||||
# move new things down
|
||||
array_set('X', 1, array_get('X', `0;X`))
|
||||
array_set('Y', 1, array_get('Y', `0;X`))
|
||||
|
||||
1
|
||||
down_heap()
|
||||
# down heap
|
||||
|
||||
|
||||
end
|
||||
|
||||
function up_heap
|
||||
# position is on the stack
|
||||
`s.`
|
||||
|
||||
# if we're at the top of heap
|
||||
return_if(`l.` == 1)
|
||||
|
||||
#`l.nl.2/dsn[|]n`
|
||||
# if we need to swap
|
||||
if array_get('X', `l.`) < array_get('X', `l.2/ds,`) then
|
||||
|
||||
# swap
|
||||
array_swap('X', `l.`, `l,`)
|
||||
array_swap('Y', `l.`, `l,`)
|
||||
|
||||
`l,`
|
||||
up_heap()
|
||||
# up heap another one
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function down_heap
|
||||
|
||||
# position is on the stack
|
||||
`dSPs,`
|
||||
|
||||
# check left
|
||||
`lP2*s.`
|
||||
if `l.` < array_get('X', 0) and array_get('X', `l.`) < array_get('X', `l,`) then
|
||||
`l.s,`
|
||||
end
|
||||
|
||||
# check right
|
||||
inc('.')
|
||||
if `l.` < array_get('X', 0) and array_get('X', `l.`) < array_get('X', `l,`) then
|
||||
`l.s,`
|
||||
end
|
||||
|
||||
# swap and more heap
|
||||
if `l,` != `lP` then
|
||||
|
||||
array_swap('X', `l,`, `lP`)
|
||||
array_swap('Y', `l,`, `lP`)
|
||||
|
||||
`l,`
|
||||
down_heap()
|
||||
|
||||
end
|
||||
|
||||
`LPst`
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
function print_heap
|
||||
|
||||
`[size: ]n0;X1-n10an`
|
||||
|
||||
for '!' in 1 to `0;X` do
|
||||
|
||||
`[priority: ]l!;Xn[ value: ]nl!;Yn10an`
|
||||
|
||||
end
|
||||
|
||||
end
|
268
src/pladcl/2024/day16/part2.pdl
Normal file
268
src/pladcl/2024/day16/part2.pdl
Normal file
@@ -0,0 +1,268 @@
|
||||
interrupt program_start
|
||||
|
||||
`1 0:X` # 1 + heap size
|
||||
# X is heap
|
||||
|
||||
# Y is values of heap
|
||||
|
||||
|
||||
end
|
||||
|
||||
state start
|
||||
|
||||
if `ln` == 'E' then
|
||||
`lisE`
|
||||
end
|
||||
if `ln` == 'S' then
|
||||
# set for iterate heap
|
||||
array_set('I', `li`, '.')
|
||||
`lisS`
|
||||
end
|
||||
|
||||
if `lw` == 0 and `ln` == 10 then
|
||||
`li1+sw`
|
||||
`0lw-0:V` # up
|
||||
`1 1:V` # right
|
||||
`lw2:V` # down
|
||||
`_1 3:V` # left
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
interrupt program_end
|
||||
|
||||
`[starting]n10an`
|
||||
|
||||
# 0123 = NESW
|
||||
`1` # start facing east
|
||||
`lS10*+` # add in start position
|
||||
|
||||
|
||||
array_set('O', `lE`, `2 32^`)
|
||||
|
||||
`sv` # value for heap
|
||||
`0sp` # priority starts at 0
|
||||
heap_add() # add into heap
|
||||
|
||||
while iterate_heap() != 1 do
|
||||
|
||||
end
|
||||
|
||||
`[backing up]n10an`
|
||||
|
||||
`0so`
|
||||
|
||||
`lE10*l++`
|
||||
backtrack()
|
||||
|
||||
|
||||
`lon`
|
||||
|
||||
end
|
||||
|
||||
function backtrack
|
||||
|
||||
end
|
||||
|
||||
function iterate_heap
|
||||
|
||||
heap_pop()
|
||||
|
||||
`lv`
|
||||
`10~`
|
||||
`sdsi` # get direction and index
|
||||
|
||||
#if we've already been here
|
||||
if array_get('L', `lv`) == 1 and array_get('O', `li`) <= `lp` then
|
||||
return 0
|
||||
end
|
||||
array_set('L', `lv`, 1)
|
||||
|
||||
`lin[ ]nlpn10an`
|
||||
|
||||
|
||||
# finish
|
||||
if `li` == `lE` then
|
||||
#`[done]n`
|
||||
# set this location as this value
|
||||
|
||||
if array_get('O', `li`) < `lp` then
|
||||
return 1
|
||||
end
|
||||
|
||||
`lds+`
|
||||
array_set('O', `li`, `lp`)
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
if `li;I` != '.' then
|
||||
#`[bad]n10an`
|
||||
return 0
|
||||
end
|
||||
|
||||
# set this location as this value
|
||||
array_set('O', `li`, `lp`)
|
||||
|
||||
|
||||
# inc cost
|
||||
`lp1+sp`
|
||||
|
||||
# forward
|
||||
`li`
|
||||
`ld;V+` # add in vector
|
||||
`10*ld+sv` # and direction
|
||||
heap_add()
|
||||
|
||||
# inc cost again
|
||||
`lp1000+sp`
|
||||
|
||||
# right
|
||||
`ld1+4%sd`
|
||||
|
||||
`li`
|
||||
`ld;V+` # add in vector
|
||||
`10*ld+sv` # and direction
|
||||
heap_add()
|
||||
|
||||
# left
|
||||
`ld2+4%sd`
|
||||
|
||||
`li`
|
||||
`ld;V+` # add in vector
|
||||
`10*ld+sv` # and direction
|
||||
heap_add()
|
||||
|
||||
0
|
||||
|
||||
end
|
||||
|
||||
function calculate_vecs
|
||||
# 0 = forward
|
||||
# 1 = right
|
||||
# 2 = down
|
||||
# 3 = left
|
||||
|
||||
if `ld` == 0 then
|
||||
`lw-`
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function heap_add
|
||||
|
||||
# priority in p, value in v
|
||||
|
||||
array_set('X', `0;X`, `lp`)
|
||||
array_set('Y', `0;X`, `lv`)
|
||||
|
||||
# up heap
|
||||
`0;X`
|
||||
up_heap()
|
||||
|
||||
# inc heap size
|
||||
#`[wow]n10an`
|
||||
array_set('X', 0, `0;X1+`)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function heap_pop
|
||||
|
||||
if `0;X` == 1 then
|
||||
`[nothing to pop]n10an`
|
||||
`5Q`
|
||||
end
|
||||
|
||||
# returns priority in p, value in v
|
||||
|
||||
# get return values
|
||||
array_get('X', 1)
|
||||
`sp`
|
||||
array_get('Y', 1)
|
||||
`sv`
|
||||
|
||||
# dec heap size
|
||||
array_set('X', 0, `0;X1-`)
|
||||
|
||||
# move new things down
|
||||
array_set('X', 1, array_get('X', `0;X`))
|
||||
array_set('Y', 1, array_get('Y', `0;X`))
|
||||
|
||||
1
|
||||
down_heap()
|
||||
# down heap
|
||||
|
||||
|
||||
end
|
||||
|
||||
function up_heap
|
||||
# position is on the stack
|
||||
`s.`
|
||||
|
||||
# if we're at the top of heap
|
||||
return_if(`l.` == 1)
|
||||
|
||||
#`l.nl.2/dsn[|]n`
|
||||
# if we need to swap
|
||||
if array_get('X', `l.`) < array_get('X', `l.2/ds,`) then
|
||||
|
||||
# swap
|
||||
array_swap('X', `l.`, `l,`)
|
||||
array_swap('Y', `l.`, `l,`)
|
||||
|
||||
`l,`
|
||||
up_heap()
|
||||
# up heap another one
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function down_heap
|
||||
|
||||
# position is on the stack
|
||||
`dSPs,`
|
||||
|
||||
# check left
|
||||
`lP2*s.`
|
||||
if `l.` < array_get('X', 0) and array_get('X', `l.`) < array_get('X', `l,`) then
|
||||
`l.s,`
|
||||
end
|
||||
|
||||
# check right
|
||||
inc('.')
|
||||
if `l.` < array_get('X', 0) and array_get('X', `l.`) < array_get('X', `l,`) then
|
||||
`l.s,`
|
||||
end
|
||||
|
||||
# swap and more heap
|
||||
if `l,` != `lP` then
|
||||
|
||||
array_swap('X', `l,`, `lP`)
|
||||
array_swap('Y', `l,`, `lP`)
|
||||
|
||||
`l,`
|
||||
down_heap()
|
||||
|
||||
end
|
||||
|
||||
`LPst`
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
function print_heap
|
||||
|
||||
`[size: ]n0;X1-n10an`
|
||||
|
||||
for '!' in 1 to `0;X` do
|
||||
|
||||
`[priority: ]l!;Xn[ value: ]nl!;Yn10an`
|
||||
|
||||
end
|
||||
|
||||
end
|
217
src/pladcl/2024/day17/part1.pdl
Normal file
217
src/pladcl/2024/day17/part1.pdl
Normal file
@@ -0,0 +1,217 @@
|
||||
interrupt program_start
|
||||
|
||||
`_1Sb` # bits ender
|
||||
|
||||
|
||||
# combo operands
|
||||
|
||||
`[0]0:C`
|
||||
`[1]1:C`
|
||||
`[2]2:C`
|
||||
`[3]3:C`
|
||||
`[lA]4:C`
|
||||
`[lB]5:C`
|
||||
`[lC]6:C`
|
||||
`[[7 combo operand]p20Q]7:C`
|
||||
|
||||
# opcodes
|
||||
`[` # adv
|
||||
`lA`
|
||||
2
|
||||
read_combo_operand()
|
||||
`^/`
|
||||
`sA`
|
||||
`]0:O`
|
||||
|
||||
`[` # bxl
|
||||
`lB`
|
||||
fetch()
|
||||
xor()
|
||||
`sB`
|
||||
`]1:O`
|
||||
|
||||
`[` #bst
|
||||
read_combo_operand()
|
||||
`8%`
|
||||
`sB`
|
||||
`]2:O`
|
||||
|
||||
`[` # jnz
|
||||
return_if(`lA` == 0)
|
||||
fetch()
|
||||
`sp`
|
||||
`]3:O`
|
||||
|
||||
`[` # bxc
|
||||
fetch()
|
||||
`st`
|
||||
`lBlC`
|
||||
xor()
|
||||
`sB`
|
||||
`]4:O`
|
||||
|
||||
`[` # out
|
||||
if `l,` == 1 then
|
||||
`[,]n`
|
||||
end
|
||||
read_combo_operand()
|
||||
`8%n`
|
||||
`1s,`
|
||||
`]5:O`
|
||||
|
||||
`[` # bdv
|
||||
`lA`
|
||||
2
|
||||
read_combo_operand()
|
||||
`^/`
|
||||
`sB`
|
||||
`]6:O`
|
||||
|
||||
`[` # cdv
|
||||
`lA`
|
||||
2
|
||||
read_combo_operand()
|
||||
`^/`
|
||||
`sC`
|
||||
`]7:O`
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
state read_A
|
||||
adjust_index(12)
|
||||
|
||||
read_number()
|
||||
|
||||
`sA`
|
||||
|
||||
set_state(read_B)
|
||||
|
||||
end
|
||||
|
||||
state read_B
|
||||
|
||||
adjust_index(12)
|
||||
|
||||
read_number()
|
||||
|
||||
`sB`
|
||||
|
||||
set_state(read_C)
|
||||
|
||||
end
|
||||
|
||||
state read_C
|
||||
|
||||
adjust_index(12)
|
||||
read_number()
|
||||
`sC`
|
||||
set_state(read_program)
|
||||
|
||||
|
||||
`0sc`
|
||||
adjust_index(10)
|
||||
|
||||
end
|
||||
|
||||
|
||||
state read_program
|
||||
array_set('P', `lc`, `ln48-`)
|
||||
inc('c')
|
||||
adjust_index(1)
|
||||
end
|
||||
|
||||
|
||||
interrupt program_end
|
||||
|
||||
|
||||
`[A:]nlAn[ B:]nlBn[ C:]nlCn[ p:]nlpn10an`
|
||||
|
||||
|
||||
`0s,` # have commaed
|
||||
`0sp` # program counter
|
||||
|
||||
`10an`
|
||||
|
||||
while `lp` < `lc` do
|
||||
|
||||
cpu_cycle()
|
||||
|
||||
#`[A:]nlAn[ B:]nlBn[ C:]nlCn[ p:]nlpn10an`
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function fetch
|
||||
array_get('P', `lp`)
|
||||
inc('p')
|
||||
end
|
||||
|
||||
function cpu_cycle
|
||||
|
||||
array_get('O', fetch())
|
||||
`x`
|
||||
|
||||
end
|
||||
|
||||
|
||||
function read_combo_operand
|
||||
array_get('C', fetch())
|
||||
`x`
|
||||
end
|
||||
|
||||
|
||||
# takes shit on the stack, leaves shit on the stack
|
||||
function xor
|
||||
|
||||
`s1s2`
|
||||
`_1Sb`
|
||||
|
||||
while `l1` != 0 or `l2` != 0 do
|
||||
|
||||
`l1 2~s3s1`
|
||||
`l2 2~s4s2`
|
||||
|
||||
0 # this bit
|
||||
if (`l3` == 0 and `l4` == 1) or (`l3` == 1 and `l4` == 0) then
|
||||
`1+` # make it 1
|
||||
end
|
||||
|
||||
`Sb`
|
||||
|
||||
end
|
||||
|
||||
0 # start at 0
|
||||
for '1' in stack 'b' do
|
||||
`2*` # double existing
|
||||
`l1+` # add in
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function read_number
|
||||
# does no error checking
|
||||
`1` # sign
|
||||
if `ln` == '-' then
|
||||
`2-` # negative
|
||||
adjust_index(1)
|
||||
end
|
||||
|
||||
`0` # c num
|
||||
while `ln` >= '0' and `ln` <= '9' do
|
||||
|
||||
`10*`
|
||||
`ln48-+` # add in number
|
||||
adjust_index(1)
|
||||
|
||||
end
|
||||
|
||||
#adjust_index(-1)
|
||||
|
||||
`*`
|
||||
|
||||
end
|
264
src/pladcl/2024/day17/part2.pdl
Normal file
264
src/pladcl/2024/day17/part2.pdl
Normal file
@@ -0,0 +1,264 @@
|
||||
interrupt program_start
|
||||
|
||||
`[this program brute forces. it probably works after 90 hours though. i solved the actual thing in a spreadsheet by hand though]n10an`
|
||||
|
||||
`_1Sb` # bits ender
|
||||
|
||||
|
||||
# combo operands
|
||||
|
||||
`[0]0:C`
|
||||
`[1]1:C`
|
||||
`[2]2:C`
|
||||
`[3]3:C`
|
||||
`[lA]4:C`
|
||||
`[lB]5:C`
|
||||
`[lC]6:C`
|
||||
`[[7 combo operand]p20Q]7:C`
|
||||
|
||||
# opcodes
|
||||
`[` # adv
|
||||
`lA`
|
||||
2
|
||||
read_combo_operand()
|
||||
`^/`
|
||||
`sA`
|
||||
`]0:O`
|
||||
|
||||
`[` # bxl
|
||||
`lB`
|
||||
fetch()
|
||||
xor()
|
||||
`sB`
|
||||
`]1:O`
|
||||
|
||||
`[` #bst
|
||||
read_combo_operand()
|
||||
`8%`
|
||||
`sB`
|
||||
`]2:O`
|
||||
|
||||
`[` # jnz
|
||||
return_if(`lA` == 0)
|
||||
fetch()
|
||||
`sp`
|
||||
`]3:O`
|
||||
|
||||
`[` # bxc
|
||||
fetch()
|
||||
`st`
|
||||
`lBlC`
|
||||
xor()
|
||||
`sB`
|
||||
`]4:O`
|
||||
|
||||
`[` # out
|
||||
read_combo_operand()
|
||||
`8%`
|
||||
`l,`
|
||||
`:U`
|
||||
|
||||
if array_get('U', `l,`) != array_get('P', `l,`) then
|
||||
|
||||
`10000sp` # break early
|
||||
|
||||
end
|
||||
inc(',')
|
||||
#`[hi]n`
|
||||
`]5:O`
|
||||
1
|
||||
`[` # bdv
|
||||
`lA`
|
||||
2
|
||||
read_combo_operand()
|
||||
`^/`
|
||||
`sB`
|
||||
`]6:O`
|
||||
|
||||
`[` # cdv
|
||||
`lA`
|
||||
2
|
||||
read_combo_operand()
|
||||
`^/`
|
||||
`sC`
|
||||
`]7:O`
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
state read_A
|
||||
adjust_index(12)
|
||||
|
||||
read_number()
|
||||
|
||||
`sA`
|
||||
|
||||
set_state(read_B)
|
||||
|
||||
end
|
||||
|
||||
state read_B
|
||||
|
||||
adjust_index(12)
|
||||
|
||||
read_number()
|
||||
|
||||
`sB`
|
||||
|
||||
set_state(read_C)
|
||||
|
||||
end
|
||||
|
||||
state read_C
|
||||
|
||||
adjust_index(12)
|
||||
read_number()
|
||||
`sC`
|
||||
set_state(read_program)
|
||||
|
||||
|
||||
`0sc`
|
||||
adjust_index(10)
|
||||
|
||||
end
|
||||
|
||||
|
||||
state read_program
|
||||
array_set('P', `lc`, `ln48-`)
|
||||
inc('c')
|
||||
adjust_index(1)
|
||||
end
|
||||
|
||||
|
||||
interrupt program_end
|
||||
|
||||
|
||||
#`[A:]nlAn[ B:]nlBn[ C:]nlCn[ p:]nlpn10an`
|
||||
`10an`
|
||||
|
||||
`0s!`
|
||||
|
||||
while 0 == 0 do
|
||||
|
||||
`l!sA`
|
||||
`0sB`
|
||||
`0sC`
|
||||
|
||||
run_program()
|
||||
|
||||
if `l!1000%` == 0 then
|
||||
`[.]n`
|
||||
#`l,n[ ]nlcn10an`
|
||||
end
|
||||
|
||||
|
||||
#`[A:]nlAn[ B:]nlBn[ C:]nlCn[ p:]nlpn10an`
|
||||
|
||||
#
|
||||
if `l,` == `lc` then
|
||||
0
|
||||
for '?' in 0 to `l,` do
|
||||
if array_get('U', `l?`) != array_get('P', `l?`) then
|
||||
`1-`
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
`s.`
|
||||
if `l.` == 0 then
|
||||
`10anl!p`
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
inc('!')
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function run_program
|
||||
|
||||
`0sp`
|
||||
`0s,`
|
||||
while `lp` < `lc` do
|
||||
|
||||
cpu_cycle()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function fetch
|
||||
array_get('P', `lp`)
|
||||
inc('p')
|
||||
end
|
||||
|
||||
function cpu_cycle
|
||||
|
||||
array_get('O', fetch())
|
||||
`x`
|
||||
|
||||
end
|
||||
|
||||
|
||||
function read_combo_operand
|
||||
array_get('C', fetch())
|
||||
`x`
|
||||
end
|
||||
|
||||
|
||||
# takes shit on the stack, leaves shit on the stack
|
||||
function xor
|
||||
|
||||
`s1s2`
|
||||
`_1Sb`
|
||||
|
||||
while `l1` != 0 or `l2` != 0 do
|
||||
|
||||
`l1 2~s3s1`
|
||||
`l2 2~s4s2`
|
||||
|
||||
0 # this bit
|
||||
if (`l3` == 0 and `l4` == 1) or (`l3` == 1 and `l4` == 0) then
|
||||
`1+` # make it 1
|
||||
end
|
||||
|
||||
`Sb`
|
||||
|
||||
end
|
||||
|
||||
0 # start at 0
|
||||
for '1' in stack 'b' do
|
||||
`2*` # double existing
|
||||
`l1+` # add in
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function read_number
|
||||
# does no error checking
|
||||
`1` # sign
|
||||
if `ln` == '-' then
|
||||
`2-` # negative
|
||||
adjust_index(1)
|
||||
end
|
||||
|
||||
`0` # c num
|
||||
while `ln` >= '0' and `ln` <= '9' do
|
||||
|
||||
`10*`
|
||||
`ln48-+` # add in number
|
||||
adjust_index(1)
|
||||
|
||||
end
|
||||
|
||||
#adjust_index(-1)
|
||||
|
||||
`*`
|
||||
|
||||
end
|
99
src/pladcl/2024/day22/part1.pdl
Normal file
99
src/pladcl/2024/day22/part1.pdl
Normal file
@@ -0,0 +1,99 @@
|
||||
state start
|
||||
|
||||
read_number()
|
||||
|
||||
`sm`
|
||||
secret_number()
|
||||
`lmlo+so`
|
||||
`[.]n`
|
||||
|
||||
end
|
||||
|
||||
|
||||
interrupt program_end
|
||||
|
||||
`10an`
|
||||
`lop`
|
||||
|
||||
end
|
||||
|
||||
# thing on stack
|
||||
function secret_number
|
||||
|
||||
for '!' in 0 to 2000 do
|
||||
|
||||
`lm64*`
|
||||
mix_and_prune()
|
||||
`lm32/`
|
||||
mix_and_prune()
|
||||
`lm2048*`
|
||||
mix_and_prune()
|
||||
|
||||
#`lmn10an`
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# thing on stack, number in m
|
||||
function mix_and_prune
|
||||
|
||||
# mix
|
||||
`lm`
|
||||
xor()
|
||||
|
||||
# prune
|
||||
`16777216%`
|
||||
`sm`
|
||||
|
||||
end
|
||||
|
||||
# takes shit on the stack, leaves shit on the stack
|
||||
function xor
|
||||
|
||||
`s1s2`
|
||||
`_1Sb`
|
||||
|
||||
while `l1` != 0 or `l2` != 0 do
|
||||
|
||||
`l1 2~s3s1`
|
||||
`l2 2~s4s2`
|
||||
|
||||
0 # this bit
|
||||
if `l3l4+` == 1 then
|
||||
`1+` # make it 1
|
||||
end
|
||||
|
||||
`Sb`
|
||||
|
||||
end
|
||||
|
||||
0 # start at 0
|
||||
for '1' in stack 'b' do
|
||||
`2*` # double existing
|
||||
`l1+` # add in
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function read_number
|
||||
# does no error checking
|
||||
`1` # sign
|
||||
if `ln` == '-' then
|
||||
`2-` # negative
|
||||
adjust_index(1)
|
||||
end
|
||||
|
||||
`0` # c num
|
||||
while `ln` >= '0' and `ln` <= '9' do
|
||||
|
||||
`10*`
|
||||
`ln48-+` # add in number
|
||||
adjust_index(1)
|
||||
|
||||
end
|
||||
|
||||
#adjust_index(-1)
|
||||
|
||||
`*`
|
||||
|
||||
end
|
106
src/pladcl/2024/day22/part2.pdl
Normal file
106
src/pladcl/2024/day22/part2.pdl
Normal file
@@ -0,0 +1,106 @@
|
||||
state start
|
||||
|
||||
read_number()
|
||||
|
||||
`sm`
|
||||
secret_number()
|
||||
`lmlo+so`
|
||||
`[.]n`
|
||||
|
||||
end
|
||||
|
||||
|
||||
interrupt program_end
|
||||
|
||||
`10an`
|
||||
`lop`
|
||||
|
||||
end
|
||||
|
||||
# thing on stack
|
||||
function secret_number
|
||||
|
||||
for '!' in 0 to 10 do
|
||||
|
||||
`lm10%sp` # previous
|
||||
|
||||
`lm64*`
|
||||
mix_and_prune()
|
||||
`lm32/`
|
||||
mix_and_prune()
|
||||
`lm2048*`
|
||||
mix_and_prune()
|
||||
|
||||
# offset
|
||||
`lm10%lp-p`
|
||||
|
||||
|
||||
|
||||
#`lmn10an`
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# thing on stack, number in m
|
||||
function mix_and_prune
|
||||
|
||||
# mix
|
||||
`lm`
|
||||
xor()
|
||||
|
||||
# prune
|
||||
`16777216%`
|
||||
`sm`
|
||||
|
||||
end
|
||||
|
||||
# takes shit on the stack, leaves shit on the stack
|
||||
function xor
|
||||
|
||||
`s1s2`
|
||||
`_1Sb`
|
||||
|
||||
while `l1` != 0 or `l2` != 0 do
|
||||
|
||||
`l1 2~s3s1`
|
||||
`l2 2~s4s2`
|
||||
|
||||
0 # this bit
|
||||
if `l3l4+` == 1 then
|
||||
`1+` # make it 1
|
||||
end
|
||||
|
||||
`Sb`
|
||||
|
||||
end
|
||||
|
||||
0 # start at 0
|
||||
for '1' in stack 'b' do
|
||||
`2*` # double existing
|
||||
`l1+` # add in
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function read_number
|
||||
# does no error checking
|
||||
`1` # sign
|
||||
if `ln` == '-' then
|
||||
`2-` # negative
|
||||
adjust_index(1)
|
||||
end
|
||||
|
||||
`0` # c num
|
||||
while `ln` >= '0' and `ln` <= '9' do
|
||||
|
||||
`10*`
|
||||
`ln48-+` # add in number
|
||||
adjust_index(1)
|
||||
|
||||
end
|
||||
|
||||
#adjust_index(-1)
|
||||
|
||||
`*`
|
||||
|
||||
end
|
88
src/pladcl/2024/day23/part1.pdl
Normal file
88
src/pladcl/2024/day23/part1.pdl
Normal file
@@ -0,0 +1,88 @@
|
||||
state start
|
||||
|
||||
`ln`
|
||||
'a'
|
||||
`-`
|
||||
`26*`
|
||||
adjust_index(1)
|
||||
`ln`
|
||||
'a'
|
||||
`-+`
|
||||
|
||||
`s1`
|
||||
|
||||
# past the '-'
|
||||
adjust_index(2)
|
||||
|
||||
`ln`
|
||||
'a'
|
||||
`-`
|
||||
`26*`
|
||||
adjust_index(1)
|
||||
`ln`
|
||||
'a'
|
||||
`-+`
|
||||
|
||||
`s2`
|
||||
|
||||
|
||||
array_set('X', `l1676*l2+`, 1)
|
||||
array_set('X', `l2676*l1+`, 1)
|
||||
|
||||
#`l1n[ ]nl2n10an`
|
||||
|
||||
adjust_index(1)
|
||||
|
||||
end
|
||||
|
||||
|
||||
interrupt program_end
|
||||
|
||||
for '!' in 494 to 520 do
|
||||
|
||||
#for '!' in 495 to 496 do
|
||||
#`l!26%`
|
||||
#'a'
|
||||
#`+an`
|
||||
for '?' in 0 to 675 do
|
||||
|
||||
#`l?n`
|
||||
#`[ ]n`
|
||||
#array_get('X', `l?676*l!+`)
|
||||
#`n`
|
||||
#`10an`
|
||||
|
||||
if not (`l?` >= 494 and `l?` <= `l!`) and array_get('X', `l!676*l?+`) == 1 then
|
||||
|
||||
#`l?n[ ]n`
|
||||
|
||||
for '@' in `l?1+` to 676 do
|
||||
|
||||
if not (`l@` >= 494 and `l@` <= `l!`) then
|
||||
if array_get('X', `l!676*l@+`) == 1 and array_get('X', `l?676*l@+`) == 1 then
|
||||
#`[wow]n`
|
||||
inc('o')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
`lop`
|
||||
|
||||
end
|
||||
|
||||
|
||||
# on stack
|
||||
function print_node
|
||||
`26~r`
|
||||
'a'
|
||||
`+an`
|
||||
'a'
|
||||
`+an`
|
||||
`[ ]n`
|
||||
end
|
117
src/pladcl/2024/day23/part2.pdl
Normal file
117
src/pladcl/2024/day23/part2.pdl
Normal file
@@ -0,0 +1,117 @@
|
||||
state start
|
||||
|
||||
`ln`
|
||||
'a'
|
||||
`-`
|
||||
`26*`
|
||||
adjust_index(1)
|
||||
`ln`
|
||||
'a'
|
||||
`-+`
|
||||
|
||||
`s1`
|
||||
|
||||
# past the '-'
|
||||
adjust_index(2)
|
||||
|
||||
`ln`
|
||||
'a'
|
||||
`-`
|
||||
`26*`
|
||||
adjust_index(1)
|
||||
`ln`
|
||||
'a'
|
||||
`-+`
|
||||
|
||||
`s2`
|
||||
|
||||
array_get('X', `l1`)
|
||||
`2l2^+`
|
||||
`l1:X`
|
||||
|
||||
array_get('X', `l2`)
|
||||
`2;1^+`
|
||||
`l2:X`
|
||||
|
||||
array_set('Y', `l1`, 1)
|
||||
array_set('Y', `l2`, 1)
|
||||
|
||||
#`l1n[ ]nl2n10an`
|
||||
|
||||
adjust_index(1)
|
||||
|
||||
end
|
||||
|
||||
|
||||
interrupt program_end
|
||||
|
||||
0
|
||||
for '!' in 0 to 676 do
|
||||
if array_get('Y', `l!`) == 1 then
|
||||
`2l!^+` # bitmap
|
||||
end
|
||||
end
|
||||
|
||||
`SP`
|
||||
`0SR`
|
||||
`0SX`
|
||||
|
||||
end
|
||||
|
||||
function bit_and
|
||||
|
||||
`s1s2`
|
||||
0
|
||||
for '.' in 0 to 676 do
|
||||
if `l12l!^/2%` == 1 and `l22l!^/2%` == 1 then
|
||||
`2l!^+`
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function bit_or
|
||||
|
||||
`s1s2`
|
||||
0
|
||||
for '.' in 0 to 676 do
|
||||
if `l12l!^/2%` == 1 or `l22l!^/2%` == 1 then
|
||||
`2l!^+`
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
# R P X stacks
|
||||
function bron_kerbosch
|
||||
|
||||
if `lP` == 0 and `lX` == 0 then
|
||||
`LRSO`
|
||||
`LPstLXst`
|
||||
return
|
||||
end
|
||||
|
||||
`0S!`
|
||||
|
||||
while `l!` < 676 do
|
||||
|
||||
if `lP`
|
||||
|
||||
`L!1+S!`
|
||||
end
|
||||
|
||||
`LPstLXstLRstL!st`
|
||||
end
|
||||
|
||||
|
||||
# on stack
|
||||
function print_node
|
||||
`26~r`
|
||||
'a'
|
||||
`+an`
|
||||
'a'
|
||||
`+an`
|
||||
`[ ]n`
|
||||
end
|
Reference in New Issue
Block a user