day 11 part 1

main
magical 2023-12-11 05:31:14 +00:00
parent 55158903e6
commit b7062a7801
3 changed files with 224 additions and 0 deletions

140
day11/input 100644
View File

@ -0,0 +1,140 @@
.#...........#.........................................................................#...............#...........#........................
.......................#....................................................................................................................
...............................#...........#.................#.............................#.............................................#..
......#............................................#........................................................................................
......................................................................#.....#.....................#.........................................
.................#.......#.......................................#................#.....#.....................#.............................
.........................................#.................#................................................................................
................................#.............................................................#..........#..................................
#.......................................................................#..............................................#.................#..
..........#....................................#......................................#............................................#........
................#....................................#........#.............................................................................
......#........................................................................#............................................................
......................#..............#..............................................................#..........#.....#......................
..................................................#.......................#..................................................#..........#...
............................#...............................................................................................................
........#...................................................................................................................................
..................#.......................#................................................................#................................
.............................................................#........#.....................................................................
..............................#.......#......................................#.............#........................#.......................
.#............................................................................................................#...........................#.
...................................................................................................#....................#...................
....................#......................#.............#.....#..................................................................#.........
.................................................................................................................#..........................
............................................................................................................................................
....................................................................#.....................#.................................................
.................................#..............................................#..............#............#.............#.................
...........................#............................................#...........................................#.......................
......................#.........................#...........................................................................................
.......................................#....................................#...................................#...........................
.....#..........#.........................................#...............................................................................#.
#..........#......................#...................................................#.......#.....#.......................................
.........................#..................................................................................................................
....................#..............................#.............#.........................................#.......#........#...............
...........................................#........................................................................................#.......
...........................................................#....................#...........................................................
..........#....................................................................................................#............................
...............#................................#..........................#..............................................................#.
..#.................................#.................................................................#.......................#.............
.....................#......#...............#........................#................................................#.....................
..............................................................................................#....................................#........
................................#.......#...................................................................................................
..........#................................................#...................#.....#..............#..........#..........#.................
.........................#..................................................................................................................
..................#...............................#...........................................................................#.............
.........................................................................#............................................#.....................
........#.....#..............................................................................#.........#..................................#.
.#...............................#......#............#.............................................................................#........
....................................................................................#.............#...............#........#................
...........................#................................................................................................................
......................#..................................#..............#................................#.............#................#...
...............................................................#..............#.............................................................
..................................#........................................................#........#.......................................
......#.................................#.......#....................#...............................................................#......
.................#............#..............................................................................#.............................#
............................................................................................................................................
..#.....................#.............................................................................#.....................................
.......................................................................................#..............................#.....................
...............................................................................#.............#..............................................
....................#.....................#...............................................................#.................................
..........#........................#............#...................#.............................................#...............#.........
............................#.............................#..........................#......................................................
...........................................................................................#................................................
.................................................................#.................................#.........................#........#.....
.................#........................................................#..................................#..............................
......................................#......................#..............................................................................
.............#...........#...............................................................................#..........#.......................
.................................#...........#...........................................................................#..............#...
.......#............................................#.....#....................#..............#.....#.......................................
...................#...........................................#................................................#...........................
........................................................................................#...................................................
...#....................#.....#............#.........................................................................................#......
...............#.............................................................#..................#........#................#.................
.........#.....................................#............................................................................................
................................................................................................................................#...........
.....................#.............#.........................................................................#..............................
.....#...............................................................................................................#..............#......#
...........#.......................................#.....#.................#.................#..............................................
............................................................................................................................................
.#.......................................#..........................................#................#......................................
......................#.............#.................#.......................#...........#.............................#...................
...............#.............#................................#......#.......................................................#..............
............................................................................................................................................
...#............................................................................................#....................#......................
..........#.....................#.............................................................................#.............................
...........................#...............................................................................................#...............#
.....................#......................................#.......#......#........#..................#...........................#........
.....#...............................#............#.........................................................................................
............................................................................................................................................
.........................................................#........................................................#.........................
#..............................#..........#..............................................................................#................#.
....................#..............................................#.......................#.........#......................................
............................................................................................................................................
...........#.......................................#.............................................................................#..........
...#......................#...............................................#......................#..........................................
..................#.........................................................................................................................
...........................................................#........#...........#.....#......#........................#.................#...
........#...................................................................................................................................
....................................................................................................#......#................................
................................#...........#....................#.....#...................................................#........#.......
........................#............#......................................#.............#.................................................
...................#............................................................................................#...........................
#................................................................................................................................#..........
..............#.............................................#...............................................................................
..............................#...............................................#.................#......................................#....
....#....................#......................................#...................#...............................#.......#...............
........................................#..........#........................................#................#..............................
............................................................................................................................................
............................................................................................................................................
........................................................................................................................................#...
...........................................................#..................#.................#.................#.........................
.......#........................................................#................................................................#..........
..........................#......#......#..................................................................................#................
...............................................#.....#.................#....................................................................
......................................................................................................#.....................................
................#....................#.....................................................................#........#.......................
..............................................................................................................................#.............
...........................................#.............................................................................................#..
....#........................#..............................#.............#................#................................................
......................#..........................................................................................#......#...................
....................................................#................................#.........#............................................
..........................#.......................................#.........................................................................
.................#........................#.....#........................................................#..................................
.#.........................................................#............#....................................................#..............
..........#..................#.....#..................................................................................................#.....
.................................................................................#..........................................................
.....................................................#....................................#.........#...........#.....#.....................
.............................................#.....................#.......................................#.......................#........
................................#...........................................................................................................
......#........................................................#..............................#.............................................
............#......................................#.....#............................#........................................#............
............................................................................#...............................................................
.......................................#...............................#...................#..............................#...........#.....
.......................#..............................#..........................#..............................#...........................
.................................................................#...................................#......................................
......................................................................................................................#...................#.
.................#..........................................................................................................................
.........#......................#.....#...........#.......................................................#.................................
...........................................#.................#................#.....................................................#.......
..#...............................................................#.........................................................................
.....................#......#......#.............................................................#............#...........#.................

10
day11/sample1.in 100644
View File

@ -0,0 +1,10 @@
...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#.....

74
day11/sol.tcl 100755
View File

@ -0,0 +1,74 @@
#!/usr/bin/env tclsh
source ../prelude.tcl
set input stdin
set map [split [string trim [read $input]] "\n"]
puts $map
proc empty {row} { return [regexp {^\.+$} $row] }
set map' {}
foreach row $map {
if {[empty $row]} {
lappend map' "${row}"
}
lappend map' $row
}
set map ${map'}
puts $map
proc column {i} {
global map
set c {}
foreach row $map {
lappend c [string index $row $i]
}
return [join $c ""]
}
set map' {}
set W [string length [lindex $map 0]]
for {set i 0} {$i < $W} {incr i} {
set col [column $i]
if {[empty $col]} {
lappend map' $col
}
lappend map' $col
}
set map ${map'}
puts [join $map "\n"]
set points {}
for {set x 0} {$x < [llength $map]} {incr x} {
set col [lindex $map $x]
for {set y 0} {$y < [string length $col]} {incr y} {
if {[string index $col $y] eq "#"} {
lappend points $x $y
}
}
}
puts $points
proc dist {x y u v} {
return [expr {abs($x-$u) + abs($y-$v)}]
}
set mins {}
foreach {x y} $points {
#set d 100000
foreach {u v} $points {
if {$u > $x || ($u == $x && $v > $y)} {
#set d [min $d [dist $x $y $u $v]]
lappend mins [dist $x $y $u $v]
}
}
#lappend mins $d
}
puts $mins
puts [ladd $mins]