Compare commits
10 Commits
29387606b0
...
1ee00e8d45
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ee00e8d45 | |||
| 952def48a0 | |||
| 08b38c2bd3 | |||
| f8c29be7ef | |||
| 19c4afdc98 | |||
|
|
616618c7e2 | ||
|
|
360ae5edbd | ||
|
|
88938a8627 | ||
| 235999524b | |||
|
|
f6f5a10270 |
291
2024/go/day06/day06.go
Normal file
291
2024/go/day06/day06.go
Normal file
@@ -0,0 +1,291 @@
|
||||
package day06
|
||||
|
||||
import (
|
||||
"adventofcode2024/utils/grid2d"
|
||||
"adventofcode2024/utils/inputs"
|
||||
"fmt"
|
||||
_ "strings"
|
||||
)
|
||||
|
||||
type Direction int
|
||||
|
||||
const (
|
||||
_ Direction = iota
|
||||
Up
|
||||
Down
|
||||
Left
|
||||
Right
|
||||
)
|
||||
|
||||
type Pos struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
type Loc struct {
|
||||
dir Direction
|
||||
pos Pos
|
||||
count int
|
||||
}
|
||||
|
||||
type Point struct {
|
||||
dirs []Direction
|
||||
display string
|
||||
}
|
||||
|
||||
func (d Direction) String() string {
|
||||
return [...]string{"-", "Up", "Down", "Left", "Right"}[d]
|
||||
}
|
||||
|
||||
func (l Loc) String() string {
|
||||
return fmt.Sprintf("Direction: %s, Position: %d %d", l.dir, l.pos.x, l.pos.y)
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
var loc Loc
|
||||
grid := inputs.ToGrid2D(input, "\n", "", "", func(c string) string { return c })
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
if grid.Get(x, y) == "^" {
|
||||
loc = Loc{dir: Up, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y) == "v" {
|
||||
loc = Loc{dir: Down, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y) == ">" {
|
||||
loc = Loc{dir: Right, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y) == "<" {
|
||||
loc = Loc{dir: Left, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println(grid.Matrix())
|
||||
fmt.Printf("%v\n", loc)
|
||||
grid.Set(loc.pos.x, loc.pos.y, "X")
|
||||
loc.count = 1
|
||||
move1(&loc, grid)
|
||||
return loc.count
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
var loc Loc
|
||||
grid := inputs.ToGrid2D(input, "\n", "", Point{}, func(c string) Point { return Point{dirs: make([]Direction, 1), display: c} })
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
if grid.Get(x, y).display == "^" {
|
||||
loc = Loc{dir: Up, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y).display == "v" {
|
||||
loc = Loc{dir: Down, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y).display == ">" {
|
||||
loc = Loc{dir: Right, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y).display == "<" {
|
||||
loc = Loc{dir: Left, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println(grid.Matrix())
|
||||
fmt.Printf("%v\n", loc)
|
||||
point := grid.Get(loc.pos.x, loc.pos.y)
|
||||
grid.Set(loc.pos.x, loc.pos.y, Point{dirs: append(point.dirs, Up), display: "X"})
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
grid = inputs.ToGrid2D(input, "\n", "", Point{}, func(c string) Point { return Point{dirs: make([]Direction, 1), display: c} })
|
||||
p := grid.Get(x, y)
|
||||
if p.display == "." {
|
||||
grid.Set(x, y, Point{dirs: p.dirs, display: "#"})
|
||||
l := loc
|
||||
if isLoop(&l, grid) {
|
||||
loc.count++
|
||||
}
|
||||
grid.Set(x, y, Point{dirs: p.dirs, display: "."})
|
||||
}
|
||||
}
|
||||
}
|
||||
return loc.count
|
||||
}
|
||||
|
||||
func isLoop(loc *Loc, grid *grid2d.Grid[Point]) bool {
|
||||
for {
|
||||
_, _, err := move2(loc, grid)
|
||||
if err != nil { return false }
|
||||
if contains(loc.dir, grid.Get(loc.pos.x, loc.pos.y)) {
|
||||
return true
|
||||
} else {
|
||||
p := grid.Get(loc.pos.x, loc.pos.y)
|
||||
grid.Set(loc.pos.x, loc.pos.y, Point{dirs: append(p.dirs, loc.dir), display: "X"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Part2b(input string) int {
|
||||
var loc Loc
|
||||
grid := inputs.ToGrid2D(input, "\n", "", Point{}, func(c string) Point { return Point{dirs: make([]Direction, 1), display: c} })
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
if grid.Get(x, y).display == "^" {
|
||||
loc = Loc{dir: Up, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y).display == "v" {
|
||||
loc = Loc{dir: Down, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y).display == ">" {
|
||||
loc = Loc{dir: Right, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
if grid.Get(x, y).display == "<" {
|
||||
loc = Loc{dir: Left, pos: Pos{x: x, y: y}}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println(grid.Matrix())
|
||||
fmt.Printf("%v\n", loc)
|
||||
point := grid.Get(loc.pos.x, loc.pos.y)
|
||||
grid.Set(loc.pos.x, loc.pos.y, Point{dirs: append(point.dirs, Up), display: "X"})
|
||||
loc.count = 0
|
||||
for {
|
||||
_, _, err := move2(&loc, grid)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
if contains(loc.dir, grid.Get(loc.pos.x, loc.pos.y)) {
|
||||
loc.count++
|
||||
break
|
||||
}
|
||||
}
|
||||
return loc.count
|
||||
}
|
||||
|
||||
func move1(loc *Loc, grid *grid2d.Grid[string]) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func move2(loc *Loc, grid *grid2d.Grid[Point]) (int, int, error) {
|
||||
x, y, err := doMove(loc, grid)
|
||||
if err != nil {
|
||||
return x, y, err
|
||||
}
|
||||
if x == loc.pos.x && y == loc.pos.y {
|
||||
move2(loc, grid)
|
||||
}
|
||||
return x, y, nil
|
||||
}
|
||||
|
||||
func canBlock(loc *Loc, point Point) bool {
|
||||
val := false
|
||||
switch loc.dir {
|
||||
case Up:
|
||||
if contains(Right, point) {
|
||||
val = true
|
||||
}
|
||||
case Down:
|
||||
if contains(Left, point) {
|
||||
val = true
|
||||
}
|
||||
case Left:
|
||||
if contains(Up, point) {
|
||||
val = true
|
||||
}
|
||||
case Right:
|
||||
if contains(Down, point) {
|
||||
val = true
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func contains(v Direction, point Point) bool {
|
||||
for _, d := range point.dirs {
|
||||
if d == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func checkMove(loc *Loc, grid *grid2d.Grid[string]) bool {
|
||||
switch loc.dir {
|
||||
case Down:
|
||||
if loc.pos.y+1 >= grid.SizeY() {
|
||||
return false
|
||||
}
|
||||
if grid.Get(loc.pos.x, loc.pos.y+1) == "#" {
|
||||
loc.dir = Left
|
||||
} else {
|
||||
loc.pos.y++
|
||||
}
|
||||
case Up:
|
||||
if loc.pos.y-1 < 0 {
|
||||
return false
|
||||
}
|
||||
if grid.Get(loc.pos.x, loc.pos.y-1) == "#" {
|
||||
loc.dir = Right
|
||||
} else {
|
||||
loc.pos.y--
|
||||
}
|
||||
case Left:
|
||||
if loc.pos.x-1 < 0 {
|
||||
return false
|
||||
}
|
||||
if grid.Get(loc.pos.x-1, loc.pos.y) == "#" {
|
||||
loc.dir = Up
|
||||
} else {
|
||||
loc.pos.x--
|
||||
}
|
||||
case Right:
|
||||
if loc.pos.x+1 >= grid.SizeX() {
|
||||
return false
|
||||
}
|
||||
if grid.Get(loc.pos.x+1, loc.pos.y) == "#" {
|
||||
loc.dir = Down
|
||||
} else {
|
||||
loc.pos.x++
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func doMove(loc *Loc, grid *grid2d.Grid[Point]) (int, int, error) {
|
||||
x := loc.pos.x
|
||||
y := loc.pos.y
|
||||
switch loc.dir {
|
||||
case Down:
|
||||
if loc.pos.y+1 >= grid.SizeY() {
|
||||
return x, y, fmt.Errorf("outside")
|
||||
}
|
||||
if grid.Get(loc.pos.x, loc.pos.y+1).display == "#" {
|
||||
loc.dir = Left
|
||||
} else {
|
||||
loc.pos.y++
|
||||
}
|
||||
case Up:
|
||||
if loc.pos.y-1 < 0 {
|
||||
return x, y, fmt.Errorf("outside")
|
||||
}
|
||||
if grid.Get(loc.pos.x, loc.pos.y-1).display == "#" {
|
||||
loc.dir = Right
|
||||
} else {
|
||||
loc.pos.y--
|
||||
}
|
||||
case Left:
|
||||
if loc.pos.x-1 < 0 {
|
||||
return x, y, fmt.Errorf("outside")
|
||||
}
|
||||
if grid.Get(loc.pos.x-1, loc.pos.y).display == "#" {
|
||||
loc.dir = Up
|
||||
} else {
|
||||
loc.pos.x--
|
||||
}
|
||||
case Right:
|
||||
if loc.pos.x+1 >= grid.SizeX() {
|
||||
return x, y, fmt.Errorf("outside")
|
||||
}
|
||||
if grid.Get(loc.pos.x+1, loc.pos.y).display == "#" {
|
||||
loc.dir = Down
|
||||
} else {
|
||||
loc.pos.x++
|
||||
}
|
||||
}
|
||||
return x, y, nil
|
||||
}
|
||||
35
2024/go/day06/day06_test.go
Normal file
35
2024/go/day06/day06_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package day06
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`....#.....
|
||||
.........#
|
||||
..........
|
||||
..#.......
|
||||
.......#..
|
||||
..........
|
||||
.#..^.....
|
||||
........#.
|
||||
#.........
|
||||
......#...`)
|
||||
require.Equal(t, 41, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`....#.....
|
||||
.........#
|
||||
..........
|
||||
..#.......
|
||||
.......#..
|
||||
..........
|
||||
.#..^.....
|
||||
........#.
|
||||
#.........
|
||||
......#...`)
|
||||
require.Equal(t, 6, r)
|
||||
}
|
||||
130
2024/go/day06/input.txt
Normal file
130
2024/go/day06/input.txt
Normal file
@@ -0,0 +1,130 @@
|
||||
...#..................#...................#......................#..............................#.............................#...
|
||||
....#.......................#........#.#..............##...........#.....#..........#..........................#..................
|
||||
.............#........................................................................#.........#.#..#..#..........#..............
|
||||
..........#.......#..........#..................#........##...................#..............#....................................
|
||||
....................#..........................................................#..#.....................................#.........
|
||||
....#............................#..............................................#.....................#..........##....#..........
|
||||
.......#.............#......................................................................#.............#.........#.............
|
||||
....###......................#....#...........#.....#................................#..........................#.................
|
||||
..........#..#...........#..#........................................................#.....#...........#................#.........
|
||||
..#....#......#....#....#...................................................................#.....................................
|
||||
....................#............#............................................#......#....#...............................#.......
|
||||
..........#.......#.........#.......#.............................................................................................
|
||||
.......#...#.......................................#...................#..........................................................
|
||||
.......#........#............................#.....#.......#..............................................#..................#...#
|
||||
.....................#.................................#................#...#...............#.....#.#..........................#..
|
||||
.....#..........................................#......................#.............##..............................#........#...
|
||||
.....#......#.........................#..........................#..........................................................#..#..
|
||||
.#......#.............#......#.................................................#.....#...................##......#................
|
||||
.............................................................................##...................................................
|
||||
........................................#.......................................#........#.............................#.#.......#
|
||||
...........#.....................................#.............................#......#......#..#....................#..#.........
|
||||
.............................................#.......................#..................##....#.....#.............................
|
||||
........................#..............................................................#..........................................
|
||||
#..............#.........................#........#...#...............#..............#..................#....................##...
|
||||
...#...#.............................#.......#................................................#........................#....#.....
|
||||
.....#.........................#..#.......................#..........#.....................#..................#.#.....#...........
|
||||
..................#........#..#.......#...................................................................................#....#..
|
||||
..#...#...............................................#.#..#........................................................#....#......#.
|
||||
...............#...............#..........................#............................#..........#.............#.................
|
||||
............#.....#........#.........................................................#........#........#.....#........#......#....
|
||||
............................#.........#....#........#.....#...#.............#.................................#...................
|
||||
........#..................#....#..........................................................#.#.#..................................
|
||||
....................................................................................................................#.............
|
||||
#............#.............#..................#......................................................................#............
|
||||
...............................#....#..........#...........##........................................................#.........#.#
|
||||
................#.........................................#.................................................#........#............
|
||||
..............................................#............#................#........#........................#...................
|
||||
..................#.........#..........................#.............#...............#............#....................#..........
|
||||
........................#...#...............................................#..............#.....#.....................#..........
|
||||
...........#.......................................#..............................#..................#....#...##..................
|
||||
#...............#..................#...............................#...............................#.....................#........
|
||||
.............#...............................................................##...................................................
|
||||
.................#.............#.......................#...#............#.#....#................................#...........#.....
|
||||
#......#......#..................................##.................#.#...............................#...........................
|
||||
.#...............#..........#...............................................#...#..........#..........#...........................
|
||||
.....................................#............................#....#.............................................#...#........
|
||||
......#...#.............#.#....................#.........#..........##.................................#..........#..........#....
|
||||
.............................#..................#....#..............##.......................#.#.....#........#...................
|
||||
.................................................#.#......................................................#................#......
|
||||
......................................#..........................................#......#.........................................
|
||||
#....................#...........................................................#..................#.............................
|
||||
.....#.........#...................................................#....#.#....#.#.........#......................................
|
||||
........#..........#......#.............#................................#.....#................#.................................
|
||||
...........#................................#...........#..........#......#.............#........................#................
|
||||
.......#...............#....................#..#................................................#.................................
|
||||
.....................#.........#..#............#..........#...........#...........#...............................#...............
|
||||
................#...#........#...........#..........................................................#..#...................#......
|
||||
.........................................................#.....................#...#......................#.#....................#
|
||||
................#......#....#.#..............#............#.......................................................................
|
||||
..........#.....................................#......................................................................#..........
|
||||
#......................................#.......#.....##..#.....................#.........#.......#................................
|
||||
........#...#..............#....................#................................#..............................................#.
|
||||
.##............................................................................#......#................................#..........
|
||||
.#........................#..............#..............................................#........#.....#.......#..................
|
||||
#......................................#.....................#...................................................................#
|
||||
............................#.....#.....#............#...............#...#.......#.........#......................................
|
||||
.#.........................#.......................#.........#.......#.................#............................#..#..........
|
||||
.............................................................................................................#........##..........
|
||||
...........#...#...#.#................#.....................................#........#............................................
|
||||
......#.......................#..........#.......#................................................................#...............
|
||||
........#....#........#..................#....##.....#............#..............................#...........#...........#..#.....
|
||||
..................................#...............................................................................#...............
|
||||
.....................#.#.......................#....................................#.............................................
|
||||
........................................................................................#.........#.................#.........#...
|
||||
..........................#..........#....#..........................................#.......................#............#.#.....
|
||||
...............................................#.#....#...............................#...................#......................#
|
||||
.....#...........#........#.#.......#.............................#..................#............................................
|
||||
...............#.........................................................#....................#.................#.............#...
|
||||
#....................................##..........#................................................................#...............
|
||||
...............#.................#...#..............#......................................................#..............#.......
|
||||
...................#......#.............................................#......................................................#.#
|
||||
..#.............#.......#......#....#..#..#.......................................................................................
|
||||
.........#....................................................#.....................................#..............#..............
|
||||
..............#..............#................................................................#.......................#...........
|
||||
..........................#.................#.......................................................##...................#.#......
|
||||
...............#..#...................................................................................................#.......###.
|
||||
...#.....................#..#........#..........#..................................................................##.............
|
||||
.................#.......................................###..............#.........................#.............................
|
||||
...#.....................................................#.......#..........................#................#..#.................
|
||||
...................................................#..................#.........................................................#.
|
||||
.....#.............#...................#...................#.....................................#................................
|
||||
.....................#.........................#......#...........................................................................
|
||||
...........#...............#......#.....##...#...#.............................................#........#.#...............#...#...
|
||||
..............#..............##...........#.......................#..#.^..........................................................
|
||||
...................#..............................................................................................................
|
||||
..................#.......#..........#.......#..................#..........#...................................#..................
|
||||
..............................................................................................#..................................#
|
||||
......................................................#................#......................#...................................
|
||||
..............#.........#..............................#.....................#......................#.............................
|
||||
#................#.........#................#.............................#......................#..#...#..............#..........
|
||||
.#..#........#................#...............#..................#........#.....................#............#........#...........
|
||||
.....................................................#.#.........#......................#.............................#........#..
|
||||
......................#.....................#..#......#..........................#............................#......#............
|
||||
......................#.........................#..#..................................#.......................#..............#....
|
||||
..........................#..................#.............#......................................................#...............
|
||||
..........................#....#........................................#..#...#....#.................#...........................
|
||||
.......#...........#.......................#............##........#....................................................#..........
|
||||
#..........................................................................#...........#..........................................
|
||||
............................................................#.................#..#........................................##......
|
||||
..#...............................................#....#.................................................##.....#...##.....#......
|
||||
...#.....##..............................#.........................................................#............#.................
|
||||
.....#....##............................#....##..........#...#....................................................................
|
||||
..................................................#..........................#.........##.......#.......................#.........
|
||||
.........#.....#..........#........#........................#.##..#............#.......................................#..........
|
||||
.....#...............#.......#..........#.#..........#.....................#.....................................#.....#..........
|
||||
....#......#............................................................................................##...#.#.#.........#......
|
||||
...........#........................#.....#....................#..................#.#........#....................................
|
||||
....................................................#................#.#................................................#.........
|
||||
..........#..............#.......................#.................#...................................#.............#.#......##..
|
||||
................##......................................................#.................#.......#.#....................#........
|
||||
................#......................................................#.............##...............#.....#......#.......#......
|
||||
..............................#............................#..........#...........#...............................................
|
||||
.......#.............#....................................................................#..............................#.#......
|
||||
...#.....................#.#...............................................................#...#..#....#..........................
|
||||
....#.........##......#..............................................................................#..................#.........
|
||||
....#..........................................#......#...................#........##............#................................
|
||||
..#.......#......#............#........#...#.#...........................#.......#................................................
|
||||
..........................#...#....................#...............#...#......#.#...#...#...............#.#.#.....................
|
||||
....##.#....................................................................#...#.....##........................#.##..............
|
||||
.............................................#....................................................................................
|
||||
140
2024/go/day07/day07.go
Normal file
140
2024/go/day07/day07.go
Normal file
@@ -0,0 +1,140 @@
|
||||
package day07
|
||||
|
||||
import (
|
||||
"adventofcode2024/utils"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Op int
|
||||
|
||||
const (
|
||||
Add Op = iota
|
||||
Mul
|
||||
Conc
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
val := 0
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
parts := strings.Split(line, ":")
|
||||
result := utils.MustAtoi(parts[0])
|
||||
numStrings := strings.Fields(parts[1])
|
||||
var numbers []int
|
||||
for _, numStr := range numStrings {
|
||||
num := utils.MustAtoi(numStr)
|
||||
numbers = append(numbers, num)
|
||||
}
|
||||
bitmask := 1 << (len(numbers) - 1)
|
||||
for i := 0; i < bitmask; i++ {
|
||||
calc := 0
|
||||
switch isNthBitSet(i, 0) {
|
||||
case true:
|
||||
calc = numbers[0] + numbers[1]
|
||||
case false:
|
||||
calc = numbers[0] * numbers[1]
|
||||
}
|
||||
|
||||
for n := 1; n < len(numbers)-1; n++ {
|
||||
switch isNthBitSet(i, n) {
|
||||
case true:
|
||||
calc = calc + numbers[n+1]
|
||||
case false:
|
||||
calc = calc * numbers[n+1]
|
||||
}
|
||||
}
|
||||
if calc == result {
|
||||
fmt.Printf("result: %v numbers:%v count: %d\n", result, numbers, bitmask)
|
||||
val += result
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
val := 0
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
parts := strings.Split(line, ":")
|
||||
result := utils.MustAtoi(parts[0])
|
||||
numStrings := strings.Fields(parts[1])
|
||||
var numbers []int
|
||||
for _, numStr := range numStrings {
|
||||
num := utils.MustAtoi(numStr)
|
||||
numbers = append(numbers, num)
|
||||
}
|
||||
operations := []Op{Add, Mul, Conc}
|
||||
results := [][]Op{}
|
||||
generatePermutations(operations, len(numbers)-1, []Op{}, &results)
|
||||
for _, op := range results {
|
||||
calc := 0
|
||||
switch op[0] {
|
||||
case Add:
|
||||
calc = numbers[0] + numbers[1]
|
||||
case Mul:
|
||||
calc = numbers[0] * numbers[1]
|
||||
case Conc:
|
||||
calc = concat(numbers[0], numbers[1])
|
||||
}
|
||||
|
||||
for n := 1; n < len(numbers)-1; n++ {
|
||||
switch op[n] {
|
||||
case Add:
|
||||
calc = calc + numbers[n+1]
|
||||
case Mul:
|
||||
calc = calc * numbers[n+1]
|
||||
case Conc:
|
||||
calc = concat(calc, numbers[n+1])
|
||||
}
|
||||
}
|
||||
if calc == result {
|
||||
fmt.Printf("result: %v numbers:%v\n", result, numbers)
|
||||
val += result
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func isNthBitSet(num, n int) bool {
|
||||
return num&(1<<n) != 0
|
||||
}
|
||||
|
||||
func getOp(row, col int) Op {
|
||||
vals := []Op{Add, Mul, Conc}
|
||||
// Column 0 cycles as row / 3
|
||||
if col == 0 {
|
||||
return vals[row/3]
|
||||
}
|
||||
// Column 1 cycles as row % 3
|
||||
return vals[row%3]
|
||||
}
|
||||
|
||||
// Recursive function to generate permutations
|
||||
func generatePermutations(ops []Op, n int, prefix []Op, results *[][]Op) {
|
||||
if n == 0 {
|
||||
// Append a copy of the current prefix to the results
|
||||
*results = append(*results, append([]Op{}, prefix...))
|
||||
return
|
||||
}
|
||||
|
||||
// Iterate over all operations and build the combinations
|
||||
for _, op := range ops {
|
||||
generatePermutations(ops, n-1, append(prefix, op), results)
|
||||
}
|
||||
}
|
||||
|
||||
func concat(a, b int) int {
|
||||
aStr := strconv.Itoa(a)
|
||||
bStr := strconv.Itoa(b)
|
||||
|
||||
concatStr := aStr + bStr
|
||||
|
||||
result, _ := strconv.Atoi(concatStr)
|
||||
return result
|
||||
}
|
||||
47
2024/go/day07/day07_test.go
Normal file
47
2024/go/day07/day07_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package day07
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/require"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`190: 10 19
|
||||
3267: 81 40 27
|
||||
83: 17 5
|
||||
156: 15 6
|
||||
7290: 6 8 6 15
|
||||
161011: 16 10 13
|
||||
192: 17 8 14
|
||||
21037: 9 7 18 13
|
||||
292: 11 6 16 20`)
|
||||
require.Equal(t, 3749, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`190: 10 19
|
||||
3267: 81 40 27
|
||||
83: 17 5
|
||||
156: 15 6
|
||||
7290: 6 8 6 15
|
||||
161011: 16 10 13
|
||||
192: 17 8 14
|
||||
21037: 9 7 18 13
|
||||
292: 11 6 16 20`)
|
||||
require.Equal(t, 11387, r)
|
||||
}
|
||||
|
||||
func TestGetOp(t *testing.T) {
|
||||
operations := []Op{Add, Mul, Conc} // Define the operations
|
||||
X := 3 // Define the number of positions (columns)
|
||||
|
||||
// Start the recursive generation with an empty prefix
|
||||
results := [][]Op{}
|
||||
generatePermutations(operations, X, []Op{}, &results)
|
||||
for _, op := range results {
|
||||
fmt.Printf("%v\n", op)
|
||||
}
|
||||
r := Add
|
||||
require.Equal(t, Add, r)
|
||||
}
|
||||
850
2024/go/day07/input.txt
Normal file
850
2024/go/day07/input.txt
Normal file
@@ -0,0 +1,850 @@
|
||||
16183610: 62 7 96 8 6 8 52 3 3 47
|
||||
408936528: 5 1 5 1 9 2 2 8 7 1 725 63
|
||||
20378697464: 101 893 487 2 6 4
|
||||
376576: 4 9 235 57 1 3 6 722 8
|
||||
431880008: 18 66 276 5 295 4 5 7 1
|
||||
379520346363: 858 95 723 8 92 7 9 2
|
||||
18243750: 76 24 3 750
|
||||
7302: 806 446 391 791 3
|
||||
18879037: 7 75 1 94 217 37
|
||||
3887037856: 805 64 71 7 9 856
|
||||
120267: 3 48 937 659 3 69
|
||||
757199: 86 2 69 7 7 8 80 5 8 743
|
||||
5835692: 349 65 110 8 1 8 35 4
|
||||
9693533: 560 33 54 523 251
|
||||
1691420808: 33 720 4 76 84 66
|
||||
27537: 5 2 2 4 296 73 89
|
||||
3099946535: 7 330 5 245 9 4 5 3 7 3 5
|
||||
2430252: 58 1 3 9 47 71 5 19 418
|
||||
379232792: 789 98 6 71 6 8 535 8 2
|
||||
11690268: 2 92 3 2 83 72 1 3 1 6 8 4
|
||||
65091: 225 4 895 1 9 6 5 6 81
|
||||
230263117372: 405 38 568 727 7 372
|
||||
1071440: 6 4 614 67 30 4 7 1 229
|
||||
60445800: 3 7 9 9 9 683 27 8 4 4
|
||||
6834722563: 95 43 29 182 9 317
|
||||
449482: 98 1 458 99 85
|
||||
381868494: 74 992 18 289 78
|
||||
42075: 86 3 28 14 38 18 225
|
||||
105275: 13 751 755 4 91
|
||||
1258023882: 4 79 534 502 61 3 3 9
|
||||
766505: 7 87 21 4 4 7 83 5
|
||||
4569436040: 355 7 6 3 4 7 8 753 4 29
|
||||
182512: 4 1 7 1 6 66 38 8 6 112
|
||||
238680: 9 42 36 65 2
|
||||
81450600: 235 52 86 6 275 2
|
||||
20684471: 2 989 98 2 4 237 3 7 59
|
||||
79521192: 48 98 9 91 5 15 29 18
|
||||
604195918: 756 74 12 2 9 52 7 8
|
||||
43646875223: 62 28 8 5 6 8 730 3 2 3
|
||||
24683153283: 5 12 2 2 462 2 72 24 3
|
||||
13641: 21 664 2 3 655 5 61
|
||||
23364264: 35 5 9 43 39 2 520 8 33
|
||||
1352375279: 9 21 54 9 84 61 527
|
||||
122558095823: 51 58 4 676 99 6 3 7 2 9
|
||||
9153847: 912 3 1 38 47
|
||||
623510: 25 63 6 30 892 86 2 5
|
||||
100277100: 352 773 45 20 90 22
|
||||
19779196416: 7 239 64 716 2 129
|
||||
5982828: 86 3 644 9 2 271 66 4
|
||||
1287462: 3 25 68 2 93 15 6 22
|
||||
11178753676: 9 9 69 3 7 2 4 8 2 6 8 8
|
||||
38798: 3 314 4 4 71 38
|
||||
15055: 1 43 7 52 3
|
||||
58769: 813 2 4 4 3 1 1 8 3 47 7 5
|
||||
716958509: 2 343 612 33 69 5
|
||||
1675: 1 28 41 19 467
|
||||
39178: 3 873 40 3 1 9
|
||||
708235: 340 13 9 2 50 385
|
||||
61112: 7 52 2 107 5
|
||||
9420: 2 9 5 70 4 13 2 468 8
|
||||
23543454: 8 478 2 87 242
|
||||
35262945144: 26 81 91 441 184
|
||||
357858: 68 4 6 9 92 7 9 92 54
|
||||
2718246046: 1 85 4 95 53 7 7 5 6 2 2 6
|
||||
575: 519 2 49 3 2
|
||||
1180: 172 18 58 44 888
|
||||
1206891306: 2 9 1 67 80 9 1 2 9 8 5 3
|
||||
1968096: 6 5 545 39 7 5 2 21 6 6 4
|
||||
74504: 744 97 7
|
||||
452256: 8 355 5 796 81 168
|
||||
418262248: 541 1 482 802 2
|
||||
152402250369: 4 87 8 8 6 319 65 369
|
||||
123797905: 9 7 550 577 1 7 2 5 3 5 7
|
||||
3129360: 73 1 7 5 62 59 20
|
||||
13030160: 58 9 4 748 65
|
||||
3758143: 7 80 6 44 6 7 1 4 17 9 4
|
||||
1058: 521 534 3
|
||||
6027582: 8 55 704 838 2
|
||||
55923132: 971 9 7 137 1 6
|
||||
42362711: 423 614 8 71 440
|
||||
74875: 89 83 85 4 57 94
|
||||
6528: 6 8 8 17
|
||||
376636: 7 9 301 12 636
|
||||
33983238: 77 8 38 925 422 51
|
||||
9773991: 76 738 2 998 6
|
||||
13324553022657: 7 4 20 5 9 5 30 22 646 9
|
||||
99691578: 5 71 1 9 4 7 325 7 1 54 7
|
||||
15561636: 4 3 74 7 10 9 7 6 6 3 3 1
|
||||
133680: 1 59 7 1 24 5
|
||||
768797: 956 3 8 375 7
|
||||
2192068: 4 4 7 2 7 22 7 2 9 97 76
|
||||
141515823: 4 8 51 515 449 3
|
||||
102779637: 902 41 6 251 3 920
|
||||
255504: 7 843 1 68 3
|
||||
6334426: 8 4 42 47 132 3 439 6
|
||||
1679200: 6 2 1 28 7 954 4 1 2 4 5
|
||||
743869: 686 85 6 56 893
|
||||
1740659638: 723 68 4 5 38 4 37 65 3
|
||||
38740803516: 696 4 198 64 36 439
|
||||
1445311524: 851 1 51 9 4 197 4 4 4
|
||||
82489: 6 13 27 26 153 22
|
||||
288151123: 5 8 95 3 4 121 6 7 5 7 7 8
|
||||
33615: 41 9 2 83 249
|
||||
235334584: 616 5 9 2 473 7 8
|
||||
18983872: 3 58 389 84 8
|
||||
966410: 117 12 622 477 3 5
|
||||
31850527: 318 32 17 741 787
|
||||
7766: 8 97 6
|
||||
3767400: 6 4 3 9 203 2 17 7 4 30
|
||||
8170454: 494 93 449 31 1
|
||||
56113624133: 5 4 7 6 502 7 9 71 7 35 3
|
||||
1070749: 2 60 64 3 986 4 6 4 9 1
|
||||
152169288123: 3 440 2 47 3 834 878 3
|
||||
23710639960: 7 7 6 2 3 4 2 395 81 2 4 4
|
||||
41133: 1 1 736 6 119 3 85 2 3 3
|
||||
2438060548: 872 65 66 8 16 5 308
|
||||
2150: 60 975 6 34 2
|
||||
42667317: 8 9 2 848 6 2 7 693
|
||||
99291: 8 52 97 811 115 69
|
||||
700480533: 152 24 4 995 533
|
||||
2043415727134: 437 668 53 7 6 6 5 13 4
|
||||
47685378032: 2 7 4 4 2 87 82 5 962 32
|
||||
1623679122582: 842 679 71 4 2 58 2
|
||||
13176069: 5 5 527 988 81
|
||||
402209662: 4 891 26 8 4 9 38 389
|
||||
62080: 86 718 329
|
||||
1056230: 475 2 5 2 553
|
||||
95017: 8 6 9 5 8 13 323 7 6 1 5 7
|
||||
130085288174: 9 9 2 9 674 36 4 2 17 4
|
||||
179095515: 2 38 6 7 6 26 9 36 8 27
|
||||
520128: 9 66 438 504
|
||||
110760: 3 8 4 7 4 60 71
|
||||
76246863: 2 80 3 3 5 75 7 761 791
|
||||
2167131616: 590 79 3 197 236 19 1
|
||||
243936484: 25 10 5 8 8 857 4
|
||||
88760: 305 4 30 6 2 9 1 70
|
||||
6539567445: 2 673 89 206 49 53 5
|
||||
802: 89 4 8 2 1 56
|
||||
198163: 55 9 8 5 5 514 273
|
||||
184378: 38 691 7 11 561
|
||||
342819000: 82 387 8 5 2 3 5 9 8 8 27
|
||||
10656324: 5 26 8 1 7 186 3 1 6 7 6
|
||||
552920982: 87 69 7 92 91 9 61 2
|
||||
20206: 1 63 1 86 79 535
|
||||
1555253: 731 36 853 960 53
|
||||
3143202608: 91 2 4 378 4 72 49 7
|
||||
108617320: 7 64 27 657 8 367 1 49
|
||||
1002415: 2 5 5 4 235 21 53 3 61 2
|
||||
554954: 96 720 227 9 8 7 1 99
|
||||
14766160525: 748 1 337 25 13 6 6 5 5
|
||||
26599060: 51 610 855 1 9
|
||||
313216: 70 93 6 92 8
|
||||
495206630906: 624 496 4 577 25 4 6
|
||||
852106300: 461 6 1 83 3 95 5 629
|
||||
338693777: 3 386 93 739 38
|
||||
84441: 50 93 2 18 647 45 13
|
||||
19591896: 3 47 87 143 888 8
|
||||
1215760: 88 32 8 7 760
|
||||
303: 8 64 9 215 7
|
||||
4493757702: 587 7 4 9 2 5 4 7 3 3 994
|
||||
45810: 6 54 4 7 4
|
||||
455911: 475 1 3 9 9 2 10 91 5 1
|
||||
21250549332: 9 7 6 6 51 18 183 43 8 9
|
||||
1651093: 716 6 3 3 1 4 1 8 8 52 4 5
|
||||
1425: 50 4 36 6 9
|
||||
240413184: 8 5 6 5 7 6 8 7 34 9 96 8
|
||||
9353: 10 13 9 8 1 1 4 4 3 7 5 8
|
||||
2098356329412: 6 57 264 714 1 5 7 651
|
||||
1366070: 18 3 2 99 220 237
|
||||
166196809: 68 59 291 20 7 284 9
|
||||
40834936: 405 659 51 3 1
|
||||
37929239: 5 739 66 518 39
|
||||
332660900: 25 96 954 572 541
|
||||
17248552687: 71 8 6 71 3 56 8 6 88
|
||||
736: 2 97 58 4 6 9 5 62 6 8 7 5
|
||||
1113308: 7 4 9 3 1 515 9 6 7 840 1
|
||||
1047862: 99 5 552 863 1
|
||||
8679: 9 6 32 5 39
|
||||
17123332: 150 3 542 72 38
|
||||
14301196: 810 535 6 33 446
|
||||
13953852: 82 2 21 94 18 844 1
|
||||
30194: 5 4 5 3 487
|
||||
299623: 40 908 79 4 55
|
||||
45472: 3 56 56 29 7
|
||||
4534682: 9 17 6 96 6 52 92 159 2
|
||||
182860020: 664 873 836 35 9
|
||||
2594594: 2 7 5 20 6 8 6 594 7 1 1
|
||||
5956711: 1 3 88 2 900 8 68 3 61
|
||||
513431: 641 64 8 98 21
|
||||
1690136: 197 191 66 66 8
|
||||
50985: 32 9 59 3 3
|
||||
1540800567: 15 30 4 16 535 567
|
||||
393181: 3 3 3 2 6 9 295 43 4 69
|
||||
152631244: 89 18 287 808 44
|
||||
49366847: 9 60 5 831 99 551 2
|
||||
47525635: 433 4 2 212 359 256 3
|
||||
313329721: 139 788 41 18 458 4 9
|
||||
48862422: 1 6 40 331 4 254 500 9
|
||||
39443910: 87 42 1 849 170 237
|
||||
130906800: 207 85 93 16 5
|
||||
220175705: 42 3 2 654 89 35 79 95
|
||||
14111: 1 6 5 8 6 8 143 510 4 9 5
|
||||
409336410: 846 720 10 8 7 5 2 1 7 6
|
||||
113011515265: 9 3 39 7 61 5 2 663 605
|
||||
2387490: 6 9 7 5 221 80 60 70 8 5
|
||||
7712: 2 7 1 155 606 2
|
||||
8043: 210 91 58 790 7
|
||||
146645: 4 407 30 3 122
|
||||
8480556: 1 8 5 922 657
|
||||
689065610: 7 141 2 698 10
|
||||
2753326: 1 141 6 5 4 1 9 39 643
|
||||
345873: 7 265 3 8 26 1 47
|
||||
74885173: 372 7 670 8 2 85 9 8 3
|
||||
136583527: 6 6 8 8 3 9 8 5 51 822 7
|
||||
3089340323: 8 64 8 1 90 477 2 4 53 3
|
||||
1096918: 195 6 886 9 920
|
||||
5367398: 535 68 80 25 98
|
||||
3976108135: 7 9 2 5 1 1 1 6 31 33 7 56
|
||||
2496005: 8 19 199 55 71
|
||||
2893997: 2 3 6 9 5 19 88 9 502 7
|
||||
557376309: 295 7 7 1 2 623 27 699
|
||||
42567659: 42 480 1 875 5 9
|
||||
15723798791671: 4 926 456 7 6 791 671
|
||||
91: 3 1 87
|
||||
75030526368: 250 695 9 692 78 8 96
|
||||
17385: 560 19 3 2 3
|
||||
616920: 3 60 879 1 582
|
||||
584294213: 8 346 7 7 4 213
|
||||
4724: 9 416 7 467
|
||||
155165: 4 11 95 2 648 4 19 125
|
||||
981426041: 4 83 7 71 3 50 9 4 5
|
||||
19972184: 2 5 31 7 2 231 2 4 4 62
|
||||
549451: 7 6 741 734 53
|
||||
5081833: 4 950 6 996 2 1 6 6 7 3 1
|
||||
1988310268: 9 3 5 707 744 14 6 8 2
|
||||
96053133326: 5 804 8 8 192 972 8 7 2
|
||||
3528: 3 11 28 3 3
|
||||
24189396: 8 3 2 171 4 4 33 28
|
||||
864165: 9 4 78 73 795
|
||||
26433000: 667 5 1 6 660
|
||||
8858: 38 1 4 206
|
||||
3200393280: 50 1 3 912 7 940 79
|
||||
2445982082: 49 1 7 94 4 86 7 64 2
|
||||
3488032730490: 73 5 6 8 57 7 8 938 490
|
||||
10071162: 8 381 15 137 3 8 8 9 1
|
||||
444: 69 6 30
|
||||
28452288677408: 480 45 5 2 6 7 90 658 8
|
||||
2593: 860 1 1 3 7
|
||||
198443470: 7 506 8 78 72 97 94
|
||||
75507: 754 2 2 85
|
||||
564275: 3 3 767 4 3 6 3 515 9 5 6
|
||||
1226: 58 4 1 276 887
|
||||
1416: 6 3 4 25 55 36
|
||||
4946042400: 9 751 929 60 65
|
||||
10626120960: 5 1 280 6 7 4 8 672 235
|
||||
222300: 10 494 15 1 3
|
||||
15905: 39 6 13 3 27 29
|
||||
89152410253: 1 27 8 2 2 6 8 8 1 518 5 3
|
||||
347293: 7 6 5 61 1 64 336 1 659
|
||||
397401: 7 7 5 20 9 9 43 1 3 7 1 3
|
||||
38394: 6 466 2 1 81
|
||||
120391: 4 9 145 4 3 7 9 8 2 6 927
|
||||
110645540: 5 180 267 1 2 9 2 143 4
|
||||
87614568: 2 4 63 32 73 213 591 4
|
||||
4709992455381: 3 6 7 2 2 955 791 9 159
|
||||
6834689: 27 6 194 8 3 689
|
||||
768: 1 16 4 5 694
|
||||
320720507: 39 660 890 7 2 7 9
|
||||
349171872: 11 36 32 82 1 89 9 6 56
|
||||
2144800: 47 79 3 5 32 25 7
|
||||
4415: 1 1 2 8 3 6 1 7 799 8 4 3
|
||||
77208: 2 322 34 7 96
|
||||
70838: 5 209 55 6 76 52 2 88
|
||||
711169603810: 9 1 9 2 20 80 74 761 1 5
|
||||
6894733854: 684 60 84 6 90 3 4 21 2
|
||||
5086572: 316 31 296 9 3 7 1 8 28
|
||||
2928408191557: 394 991 42 5 5 4 75 7
|
||||
509332682: 5 1 4 37 834 58 7 5 68 2
|
||||
13102440337: 1 6 3 780 5 8 3 37
|
||||
10878341: 9 90 612 170 45 41
|
||||
498132911: 4 911 685 999 89
|
||||
958999: 683 23 61 6 5 17 722
|
||||
143343: 88 59 9 92 751 210 3
|
||||
2743510584: 6 706 6 385 584
|
||||
251973: 424 66 5 8 9
|
||||
10183308: 169 709 9 5 3 9 67 2 46
|
||||
749315: 464 4 4 68 10 2 2 203
|
||||
92707239: 6 522 50 4 2 74 1 6 25 8
|
||||
82155646350715: 4 87 2 84 9 463 507 15
|
||||
87924480: 281 975 789 320
|
||||
60415: 5 804 3 23 5
|
||||
971347: 83 13 9 2 47
|
||||
17037310: 7 811 3 6 310
|
||||
15333: 535 78 95 99 19
|
||||
23713: 3 2 39 519 877
|
||||
29532875: 29 5 32 563 118 194
|
||||
6455904009: 221 6 9 4 2 4 26 112 9
|
||||
57785406: 96 140 7 55 186 26 6 7
|
||||
48: 1 3 12
|
||||
215140: 8 317 5 3 8 4 4 40 9 3 2 2
|
||||
9406542: 9 5 39 9 5 653 511 219
|
||||
8396187: 7 904 477 3 148 87 2
|
||||
734384430: 56 485 9 1 507 4 9 130
|
||||
484993118067: 81 402 993 345 6
|
||||
287773: 1 783 2 814 267 7 4 7 3
|
||||
36777312: 47 6 66 8 247
|
||||
4740447723: 2 36 3 10 3 355 8 73 1 3
|
||||
866755680: 460 3 3 991 1 5 6 6 19
|
||||
290326138: 5 285 317 8 83 38
|
||||
13602050748: 801 13 5 1 49 7 314 99
|
||||
61360: 9 543 8 53 60
|
||||
1787: 321 5 82 6 3 80 9
|
||||
233760: 7 429 313 5 4 77 4 296
|
||||
7665: 87 5 11 17 83
|
||||
26991479: 26 1 8 6 6 6 12 7 7 3 5 76
|
||||
18712: 6 74 13 974 56 1 7 9 7 3
|
||||
217: 7 87 2 3 26
|
||||
64867314: 2 90 9 5 8 492 1 4 1 257
|
||||
318200694: 2 3 739 7 1 861 63
|
||||
3282485321: 82 4 248 521 3 106
|
||||
156568734: 7 2 8 6 4 36 769 7 5 1 6 9
|
||||
832433113: 36 909 158 161 1
|
||||
33661685163: 7 2 7 42 49 1 9 80 342 3
|
||||
1924152: 5 83 51 9 677 998 8
|
||||
5297870114599: 141 899 89 5 839 99
|
||||
429345221: 9 471 63 7 45 2 21
|
||||
656: 7 27 9 15 7 2
|
||||
75577: 34 855 85 6 6
|
||||
1215357: 2 922 57 28 210 29 3
|
||||
1595334418735: 6 676 272 86 184 3 35
|
||||
5453: 7 683 5 31 542 94
|
||||
154076: 3 414 4 74 1 1 88 1 604
|
||||
355: 44 8 3
|
||||
33370224183: 71 470 224 122 64
|
||||
39385509782: 3 2 712 454 6 442 86
|
||||
69169117: 1 2 492 14 91 17
|
||||
1312: 44 51 55 890 272
|
||||
168008743: 8 50 42 87 34 9
|
||||
487800: 48 7 19 72 48 75
|
||||
13370112: 8 5 49 9 81 6 724 9 4 1 7
|
||||
42823680: 5 1 6 9 9 5 96 34 32
|
||||
8791740: 1 62 807 3 54
|
||||
56457986: 60 9 6 32 9 49 568 221
|
||||
113219: 78 200 8 409 43
|
||||
54394: 8 99 89 90 5
|
||||
378625170008: 77 496 8 83 125 61 1 8
|
||||
278244129: 5 6 176 93 630 770 2 9
|
||||
558711270: 10 9 7 7 8 2 550 97 9 9
|
||||
119: 1 8 9 43 58
|
||||
4219093863: 1 4 3 5 609 98 31 63 1
|
||||
13341355: 42 910 954 14
|
||||
10052058: 904 699 63 9 34 3 6
|
||||
48462: 4 5 5 66 301
|
||||
75699471: 4 34 942 942 82 4 347
|
||||
4544506132: 5 3 7 5 247 1 5 9 9 1 1 32
|
||||
52896: 68 279 1 76 76 1 2
|
||||
258536924: 8 5 8 2 7 3 86 690 9 1 12
|
||||
288662: 5 26 2 75 5 3 172 41 2 3
|
||||
26390: 48 59 931 7 7
|
||||
102081: 324 693 2 36 1
|
||||
128487268: 38 7 83 6 39 81 97 1 4
|
||||
19224: 3 9 1 8 89
|
||||
81432540: 501 20 7 387 3
|
||||
738: 20 9 4 2 7 435
|
||||
29516544: 87 2 7 557 8 69
|
||||
1296424278: 6 666 6 31 857 54
|
||||
479149020: 5 6 987 261 62
|
||||
1883704: 9 638 8 8 41
|
||||
7480260: 4 8 7 534 9 102 2 7 8 18
|
||||
1475107: 29 37 30 745 7
|
||||
1693: 17 97 1 9 35
|
||||
896075: 792 1 862 5 2 53 9 8 6 5
|
||||
2470: 151 1 1 2 2 2 608 2 7 3 4
|
||||
45069234: 82 177 29 539 6
|
||||
241893540: 824 820 358 79 10 11
|
||||
191130028: 685 7 8 4 25 92 5 4 3 16
|
||||
8853318: 693 285 5 39 31 2 9
|
||||
18827664945: 4 9 1 45 8 6 4 9 82 757 5
|
||||
4116: 1 564 14 7 70
|
||||
176837684: 7 5 22 10 4 73 5 4 7 83 2
|
||||
1896818086: 12 931 5 409 5 2 4 1 6
|
||||
105489753097: 6 17 9 841 5 4 1 7 8 29
|
||||
40161623048: 352 63 98 3 55 4 7 2 4
|
||||
1588: 8 21 3 27 8 4
|
||||
557431350: 25 486 9 26 589 25 70
|
||||
344082613: 47 8 5 8 4 9 2 2 4 802 13
|
||||
54844287: 548 44 27 1 4
|
||||
2009988: 293 98 7 4 4
|
||||
1460: 9 5 3 9 7 9 4
|
||||
531060398227: 4 37 897 9 4 398 227
|
||||
370163550: 9 48 1 8 67 12 70 3 747
|
||||
607921609: 5 476 7 37 30 790 9
|
||||
142843: 2 27 80 33 12 271
|
||||
1491: 729 646 86 24 6
|
||||
710723510: 17 469 9 3 53 8 86 3 70
|
||||
101165: 37 495 19 6 79
|
||||
4068792: 3 7 432 8 3 13
|
||||
22305981: 9 3 348 4 1 5 3 2 65 2 89
|
||||
1969800068778: 500 201 196 687 78
|
||||
1968: 105 7 1 51 12
|
||||
60750717: 45 2 9 75 717
|
||||
57464640: 1 85 651 2 8 2 81 3 2 5 2
|
||||
200314094445: 4 8 7 5 7 66 8 1 880 8 9 5
|
||||
8486: 2 963 1 6 7 7 1 6 2 337 2
|
||||
313862603: 71 5 92 961 3
|
||||
13295: 3 257 9 50 5
|
||||
567600: 7 4 572 946
|
||||
68737952352: 318 23 1 2 6 9 2 8 3 144
|
||||
3564807348: 35 47 202 9 298 57 4
|
||||
689871030: 19 95 980 3 26 6 5
|
||||
94380: 1 9 71 5 66 2
|
||||
2781516: 6 5 603 20 61 492 386
|
||||
13274353131: 3 4 466 1 1 87 8 963 1 8
|
||||
1114: 838 95 19 90 72
|
||||
265690: 9 119 8 31 82
|
||||
4914768: 505 5 968 48 17
|
||||
20054848: 9 2 3 97 3 6 3 34 58 11 4
|
||||
25408: 773 8 4 2 670
|
||||
12692025489: 6 504 54 226 9 1 8 11
|
||||
290762983266: 7 1 8 7 38 1 6 998 14 9 6
|
||||
11062: 173 7 56 250 4 9 4 715
|
||||
2047569858: 12 5 91 17 21 81 2 9
|
||||
36882: 237 4 751 961 2 827 6
|
||||
604145841: 3 5 9 8 4 5 823 4 634 41
|
||||
3706712: 3 706 710
|
||||
1958107: 1 325 6 8 6 4 4 1 1 60 6 1
|
||||
310883145: 4 816 618 4 8 31 45
|
||||
86120982: 4 41 221 6 66 866 7 6
|
||||
2773830: 231 76 3 9 9 30
|
||||
75367563264: 6 83 2 6 8 6 76 9 8 7 1
|
||||
22134: 3 90 238
|
||||
7551233910: 839 9 163 70 910
|
||||
153182070: 50 2 1 7 6 84 30 7 5 9 31
|
||||
6210421: 7 763 8 2 1
|
||||
14047776281: 5 67 852 229 281
|
||||
2203652320: 807 8 63 602 1 9 7
|
||||
233435: 9 715 1 9 41 399 1 4 8 7
|
||||
1257131: 5 94 1 16 1 95 502 629
|
||||
26088: 10 8 6 466 953 9 48 9 2
|
||||
35581368: 5 9 75 912 6 62 438
|
||||
606056: 6 11 5 194 44
|
||||
1552572: 85 761 3 2 9 6 18 4
|
||||
253947: 3 2 627 81 12
|
||||
5051760736: 3 786 571 469 50 8
|
||||
358540: 9 64 306 28 394
|
||||
561644260: 5 61 1 4 3 6 5 4 247 11 2
|
||||
1778294250: 9 15 242 9 42 144 810
|
||||
7710: 8 2 753 10 4 16
|
||||
193140: 20 498 3 4 7 55 15 6
|
||||
502578: 9 84 900 63 6
|
||||
43946: 26 42 643 24 39 159
|
||||
6279695: 1 6 5 4 60 57 1 9 95 6 2 3
|
||||
2372052: 8 8 8 80 44 2 3 7 9 516
|
||||
55286: 610 308 47 4 57 8 45
|
||||
11313: 85 435 604 6 1 3
|
||||
1172701075: 8 842 21 461 9 25 7
|
||||
1797522636: 590 8 52 3 578 44 392
|
||||
971889: 5 235 71 26 30 9
|
||||
4481: 648 4 8 166 1 291 4 9
|
||||
33050: 4 46 661
|
||||
28350171951: 4 146 945 859 75 2 1
|
||||
20126581497: 17 9 491 229 494 3
|
||||
219611747: 9 421 966 60 549 758
|
||||
1240: 53 6 3 7 1
|
||||
1063335085: 7 505 96 3 6 7 975 1 8 5
|
||||
1055: 6 52 29 2 6 11
|
||||
7469925625: 5 38 2 1 7 59 6 86 20 5
|
||||
35653113: 3 5 653 11 3
|
||||
149744: 53 897 49 1 40 9 8 2 8
|
||||
93519: 1 894 233 7 16 9 39 2 9
|
||||
11332409040413: 7 8 418 7 502 4 90 413
|
||||
143916476: 2 497 3 57 961
|
||||
7467000: 8 14 900 388 300 19
|
||||
198360845: 6 121 119 56 3 41 98
|
||||
353309832209: 6 1 36 8 2 9 9 44 3 211
|
||||
128: 6 6 2 50 6
|
||||
50422922685: 340 92 73 61 362 605
|
||||
1044844: 3 7 4 4 844
|
||||
9193: 5 79 3 76 3
|
||||
30090: 14 16 3 131 8 259 77 9
|
||||
337279: 37 4 9 13 658 8
|
||||
168780: 28 9 6 17 64 4 3 4 87 5
|
||||
642: 77 6 8 7 2
|
||||
7672557939275: 25 643 5 76 88 34 7 5
|
||||
19552214: 702 29 2 8 9 480 374
|
||||
354663185: 7 9 3 325 6 3 574 6 3 2 5
|
||||
525: 4 7 460 54
|
||||
599351195625: 2 38 4 45 625 573 689
|
||||
1965880: 220 960 34 49
|
||||
714: 13 3 3 2 6
|
||||
3955502937502: 3 6 75 586 2 93 1 6 502
|
||||
2814600: 2 2 6 14 4 83 23 20 74 1
|
||||
5382626: 5 887 8 9 771 26
|
||||
2985: 42 70 45
|
||||
114040: 86 805 270 99 90 640
|
||||
9758700: 3 11 8 35 2 47 5 7 150
|
||||
100502: 56 9 7 82 8 4 1 9 9 305
|
||||
414969404544: 4 317 8 6 41 9 7 9 64 96
|
||||
1842483: 1 59 3 3 2 9 2 7 1 60 9 3
|
||||
21282606: 4 21 883 518 942
|
||||
127405: 1 447 285 9 1
|
||||
142043: 2 84 8 804 139 400
|
||||
28834136: 47 5 607 1 5 1 10 148 6
|
||||
2624860: 28 4 2 9 9 2 217 85 45 7
|
||||
17295642442: 994 174 406 15 3 42
|
||||
446792: 76 1 5 5 58 19 2
|
||||
35078400: 29 14 25 8 9 6 8
|
||||
35933488: 8 927 948 537 218 1 8
|
||||
2054: 2 54 1 35 59
|
||||
5752100560: 729 935 27 394 20
|
||||
1460: 8 78 3 36 2 1 794
|
||||
2092: 92 2 6 482 2
|
||||
132844416: 3 73 8 16 8 5 53 5 6 914
|
||||
1040: 2 1 8 13 65 5
|
||||
3776340861: 5 6 43 4 807 9 30 3 327
|
||||
211646: 737 7 1 2 41 45
|
||||
2478488900: 912 677 9 320 6 8 446
|
||||
6346890: 79 13 64 549 21 9 3
|
||||
10743769823: 2 9 9 366 2 9 213 5 7 4 3
|
||||
384744: 1 7 45 9 1 53 8 9 1 2 3 92
|
||||
11120158342: 94 2 3 863 118 2
|
||||
489775464841: 754 909 829 862 9 4
|
||||
51328938: 7 8 9 4 3 172 73 8 9 1
|
||||
3792391: 50 8 89 5 11 141 193 3
|
||||
1677592: 79 87 20 6 9 16 5 2 56
|
||||
471: 9 14 8 7 433
|
||||
1107101: 3 367 7 198 5 7 1 98 4 9
|
||||
47200: 2 9 3 17 944
|
||||
3348321304: 5 813 9 1 520 64 7 4 4 9
|
||||
1739519: 66 19 428 57 519
|
||||
22440: 8 4 9 54 4 9 165 846 17
|
||||
821576: 9 31 6 5 79 1 2 8 9 7 5 56
|
||||
2668212268: 193 9 6 929 17 9 2 9 70
|
||||
107258248: 5 39 55 824 8
|
||||
16886076: 86 798 850 2 10 9 27 6
|
||||
15150915: 23 77 8 9 89 97 15
|
||||
5495112: 4 9 3 27 652 3 329 8 8
|
||||
3731250172: 18 923 206 765 957
|
||||
712: 7 82 7 70 61
|
||||
1690608385: 950 8 59 36 754 933 5
|
||||
211704: 4 73 5 5 29 4
|
||||
13350938: 9 13 690 26 878 70
|
||||
1078: 4 75 3 58 938
|
||||
63265042924: 8 6 92 1 1 530 8 2 924
|
||||
133796: 88 12 6 1 31 2 1 991 2
|
||||
1568: 47 9 365 578 202
|
||||
8272201: 32 68 5 887 703
|
||||
1577492: 46 517 38 1 28
|
||||
196963074: 84 5 1 63 47 6 29 5 198
|
||||
886296: 87 7 35 894 6
|
||||
31327600: 175 117 765 2 847 3
|
||||
253681: 8 1 40 23 775 45 3 7 7 2
|
||||
17514480: 43 377 18 79 31 60
|
||||
910107: 912 319 400 558 1 9
|
||||
161: 3 3 4 2 83 9 21
|
||||
40413945600: 405 172 56 280 37
|
||||
3789: 87 2 35 650 24
|
||||
27022: 4 4 32 5 600 22
|
||||
197568: 257 9 3 1 36 84
|
||||
328307113: 377 3 6 45 87
|
||||
151439: 95 56 423 16
|
||||
259661768400: 920 49 2 33 57 6 33 48
|
||||
423: 1 2 5 8 4 6 1 4 62 7 35 3
|
||||
46979865: 446 9 8 7 209 4 5
|
||||
645844904: 913 3 32 7 921 349 9 8
|
||||
2626745581: 7 4 4 96 770 9 5 581
|
||||
563611272336: 84 52 5 5 4 6 98 126 6 3
|
||||
2816515701: 4 305 5 13 93 8 5 7 6
|
||||
7008: 3 24 43 7 6 1
|
||||
3843804: 114 9 6 880 67 3 4 680
|
||||
11489089: 29 882 67 32 5 14 59
|
||||
532035739: 604 586 2 440 59
|
||||
400471397473: 6 674 52 1 3 2 911 6 4 1
|
||||
125805007: 8 4 5 2 3 2 9 7 51 5 60 7
|
||||
3731005: 37 30 952 4 49
|
||||
26168970: 873 7 4 1 704 26 7 33 6
|
||||
18249174: 249 25 74 86 9
|
||||
14153474251: 6 471 6 3 9 6 9 6 9 450 1
|
||||
1685466: 4 921 82 678 466
|
||||
50708: 8 546 191 67 793
|
||||
1789646: 7 4 2 52 1 6 2 910 787 8
|
||||
113086575: 136 85 1 323 95 75 21
|
||||
763: 60 3 3 157
|
||||
756109819: 1 2 7 90 258 9 1 4 621 9
|
||||
99331: 610 597 94 38 9 2 437
|
||||
5591282: 31 5 662 9 2 4 84
|
||||
68420: 76 7 2 1 4 3 5 5 517 8 8 4
|
||||
120380: 4 9 6 553 924 8
|
||||
663053160: 4 2 6 14 5 4 9 5 2 6 365 2
|
||||
26825461: 609 28 7 1 9 109 6 52 9
|
||||
41360: 2 19 3 2 3 899 6
|
||||
20393: 1 49 4 3 93
|
||||
2084013: 781 26 3 9 257
|
||||
1667257110288: 3 69 8 28 41 204 77 7
|
||||
430950: 14 1 8 8 18 7 4 6 7 2 6 5
|
||||
52577: 6 28 9 295 356 6
|
||||
10006634: 7 1 25 5 6 634
|
||||
262290534: 82 9 8 3 6 95 3 18 4 92 6
|
||||
67866: 31 650 73 9 6
|
||||
1575: 9 58 1 3 6
|
||||
59124: 8 2 9 2 32 3 845 1 23 4 4
|
||||
1013226: 3 588 5 3 94
|
||||
223242318: 7 8 55 5 16 22 2 423 18
|
||||
1156716300: 1 201 5 191 828 299 1
|
||||
304170059558: 452 46 8 950 6 59 558
|
||||
16721: 4 68 9 4 7 1 60 2 2 7 3 2
|
||||
3270361: 8 1 110 8 638 2 7 4 85
|
||||
810506452: 66 458 4 349 554 4 6 2
|
||||
67695107: 955 7 8 7 2 268 87 30 7
|
||||
1799821: 2 9 52 4 4 1 20 11
|
||||
4416: 43 2 6 3 6
|
||||
10554182: 9 2 4 84 5 8 80 58 6 38
|
||||
139: 8 6 53
|
||||
175460066367: 18 8 66 6 738 930 27
|
||||
2080368820: 3 32 1 3 9 3 1 90 99 8 28
|
||||
217175: 214 2 605 570
|
||||
370333248: 9 80 559 33 928 586
|
||||
47: 6 6 35
|
||||
2499: 52 6 2 2 81 2 1 9
|
||||
398476: 4 108 97
|
||||
277326: 13 795 462 3 5 31 7
|
||||
444588700: 444 17 41 86 41 59
|
||||
140: 9 52 1 72 7
|
||||
151004081: 4 47 3 99 341 9 65
|
||||
117335040: 55 6 1 68 9 863 1 384 8
|
||||
5381424859: 2 989 1 4 2 8 18 7 6 9 8
|
||||
972371: 11 81 60 176 851
|
||||
75170: 6 3 683 71 28 471
|
||||
939123289: 51 8 43 158 93 36 289
|
||||
1129468656: 975 25 47 492 94
|
||||
59856: 1 7 539 2 19 57 222 43
|
||||
48186761: 7 894 77 99 62
|
||||
507835: 50 5 9 9 9 9 1 5 39 1
|
||||
95273700: 8 574 52 16 705 29
|
||||
20660493280: 7 529 32 49 70 560
|
||||
6624696: 8 6 507 5 1 8 9 85 7 7 34
|
||||
15010074378: 8 7 56 4 8 4 3 5 3 354 6 3
|
||||
678375368: 700 20 4 597 968
|
||||
29457249523: 2 9 12 6 4 3 2 72 495 23
|
||||
124197303: 114 675 807 2 3
|
||||
952: 5 3 7 91 31 6 749 7 1 5 7
|
||||
105460: 8 15 88 950 10
|
||||
2474: 87 9 99 995 597
|
||||
82448: 12 4 9 58 1 34 1 1 3 2 3 4
|
||||
200852169: 83 216 5 1 22 4 3 4 3 7
|
||||
15804: 644 95 836 7 47
|
||||
51172: 6 80 9 1 9 487 9 8 4 9 4 3
|
||||
18716470110: 7 7 92 4 9 9 5 3 299 30
|
||||
1104115320: 7 51 5 55 2 11 396 70
|
||||
23730820: 4 6 7 468 96 2 23 450 3
|
||||
1001067516: 2 6 1 1 22 218 2 1 892 9
|
||||
43248548: 4 324 1 7 2 9 69 373 6 1
|
||||
15903155187792: 90 16 503 18 73 2 92 6
|
||||
8504979: 4 83 2 5 8 7 7 64 73 74
|
||||
363303: 404 580 41 23 9
|
||||
227343: 7 77 268 9 481 1 90 3 3
|
||||
326565: 815 40 9 468 3 85
|
||||
7695: 2 2 85 6 81
|
||||
39343: 80 49 2 72 69
|
||||
61878: 86 58 9 295 138 54
|
||||
1863313: 4 41 68 8 7 314
|
||||
81640800: 1 69 3 493 800
|
||||
159012: 37 80 6 2 21
|
||||
9700215: 8 5 1 446 8 2 2 61 105 1
|
||||
58789: 202 628 35 6 3 2 1 671
|
||||
3072485: 6 45 337 94 487 9 2
|
||||
256800: 2 8 8 6 535
|
||||
283078917: 5 7 733 38 30 39 3 309
|
||||
34675: 47 8 3 4 5 995 4 5 4 175
|
||||
15603: 4 14 832 364 263
|
||||
3938405130: 1 8 715 46 1 3 2 8 5 6 51
|
||||
1769660661: 7 2 5 2 2 3 103 35 7 426
|
||||
1609545534: 32 2 83 7 55 37 7 5 89 6
|
||||
77820294491: 6 63 2 917 1 64 17 74
|
||||
11220481: 3 33 3 3 83 1 3 6 640 1
|
||||
2658459: 771 1 9 71 8 2 5 59 1 8 3
|
||||
1599441406: 416 6 89 8 5 900 7 8 91
|
||||
156508013: 9 3 92 6 57 2 440 8 1 1
|
||||
8346: 5 8 182 686 380
|
||||
231984743: 9 72 888 7 38 9 7 607 3
|
||||
21601: 37 6 2 132 7 96 1
|
||||
724: 27 317 27 274 79
|
||||
55994878860: 38 9 34 799 5 9 2 4 9 4
|
||||
4631: 1 40 16 7 39
|
||||
712350654: 857 68 17 18 453
|
||||
229674: 1 723 402 36 58 3
|
||||
2100: 843 740 55 76 386
|
||||
921150275: 51 64 890 9 275
|
||||
734929386: 632 380 4 9 90 34 6
|
||||
2669199: 97 5 7 95 922 7 9 6 8 6 1
|
||||
1500039: 2 7 331 3 6 2 3 8 1 9 27 9
|
||||
72048: 240 650 9 49 76
|
||||
1660302: 113 25 5 850 22 76 4 2
|
||||
511746807: 47 9 809 9 465 807
|
||||
38019125: 369 68 87 11 9 6
|
||||
4527: 6 6 9 45 293 5 2 4 2 691
|
||||
242568: 8 24 6 341 64 8
|
||||
427: 3 81 4 91 1
|
||||
23195120: 22 198 655 342 120
|
||||
360: 9 6 4 2 3
|
||||
6853: 79 6 78 216 7
|
||||
35758: 336 21 1 43 8 6 1
|
||||
2179618: 7 70 70 4 680 1 98
|
||||
9606: 86 4 2 3 943
|
||||
26749464: 1 5 433 5 717 98 84
|
||||
776037573: 8 8 894 9 577 6 621 9
|
||||
799293: 99 8 76 2 4 4 6 1 3 5 31 3
|
||||
2691671: 1 7 6 2 1 4 1 12 65 668 3
|
||||
1544: 898 24 1 496 99 27
|
||||
68191364: 42 990 2 2 82
|
||||
524438312: 524 4 382 42 70
|
||||
8831455: 5 2 7 29 5 435 2 76 879
|
||||
434271927: 649 708 8 725 73 4 7
|
||||
88569642727: 885 69 642 7 27
|
||||
663: 204 17 3
|
||||
38449: 2 65 6 1 1 8 1 2 56 8 369
|
||||
392709: 28 177 117 2 50 5 7 3 9
|
||||
58033879: 8 725 4 9 7 8 16 570 1 9
|
||||
94154: 150 22 5 86 358
|
||||
43361102577534: 7 5 59 634 69 749 966
|
||||
2026946: 8 257 6 983
|
||||
5551744: 3 9 9 9 79 661 51 7 8 4
|
||||
467134789: 819 596 957 92 29
|
||||
1434: 1 5 1 6 8 520
|
||||
1660075: 217 34 83 710 8 7 38 1
|
||||
104704026560: 2 8 7 4 6 5 9 429 5 20 7 4
|
||||
3362348024: 7 4 601 27 3 897 5 7
|
||||
967272990: 17 30 354 9 559 9 64
|
||||
695308: 69 436 8 86 854
|
||||
617664: 4 19 879 684 696
|
||||
280208148: 365 766 618 143 4
|
||||
11358272: 74 3 5 44 43 11 29 63 2
|
||||
102: 25 2 8 67 1
|
||||
148752720571: 5 693 265 6 10 9 19 3 1
|
||||
9326675237: 4 658 325 28 56 774 5
|
||||
63112912358: 63 11 29 123 6 1
|
||||
689052595: 202 96 7 7 485
|
||||
6261: 8 4 31 16 93 8 13
|
||||
1143244033: 857 230 95 9 29 2 1
|
||||
4077224042: 5 343 675 763 17
|
||||
148967182: 91 464 855 38 91
|
||||
13013: 261 7 9 23 7
|
||||
151402: 2 7 65 119 8 8 484 2 2
|
||||
1162841: 4 653 7 444 5
|
||||
122954: 931 42 59 1 119 25
|
||||
8802293760: 8 6 5 2 7 248 208 5 72 6
|
||||
882283627: 2 60 762 28 29 68 659
|
||||
119320851948: 4 6 9 3 2 736 8 3 5 65 8 6
|
||||
363560: 599 2 9 551 61
|
||||
79156980000: 12 75 3 35 8 5 487 43
|
||||
2016471: 8 80 2 5 9 9 1 5 7 66 90
|
||||
541898: 7 906 63 68 6
|
||||
8691: 44 4 41 2 4
|
||||
57859465: 582 9 60 978 6 5 974
|
||||
969507840: 8 5 3 520 71 4 254 7 3 1
|
||||
111331: 14 9 2 8 4 3 1 40 188 3
|
||||
79296: 9 72 2 52 62 4 2 48 7
|
||||
99752561604: 25 783 42 2 4 32 2 482
|
||||
260196: 85 8 466 6 2 104 53 9
|
||||
54308747928: 84 978 7 115 1 6 958
|
||||
177610113: 5 12 4 679 5 23 457 9
|
||||
291015504: 409 342 4 702 138
|
||||
111029044: 7 658 506 16 57 7 844
|
||||
4431074491353: 263 96 287 7 27 650
|
||||
61459200: 3 3 3 37 4 805 2 30 80 9
|
||||
4938: 2 6 7 7 7 586 74 4 130 6
|
||||
724927: 1 687 9 1 13 80 47
|
||||
176219199: 8 533 928 1 351
|
||||
7061236841: 52 30 20 299 859
|
||||
1680930: 56 9 2 120 1 799 8 2 95
|
||||
22230091458: 5 780 57 91 4 61
|
||||
618962: 618 8 7 9 1
|
||||
979087974: 896 52 407 2 5 53 393
|
||||
1076124: 3 42 7 761 124
|
||||
39804061: 3 6 7 9 3 2 3 685 535 6 1
|
||||
617371560: 9 2 6 77 1 83 4 26 9 10 1
|
||||
59292627728: 244 243 62 77 28
|
||||
60679755965: 81 7 1 3 19 57 687 65
|
||||
385718461: 2 6 873 908 8 3 3 3 2 24
|
||||
70068614: 5 2 19 383 178 887 7 7
|
||||
81627: 812 1 8 236 87 45 41
|
||||
61252920: 7 396 200 229 90
|
||||
122349515906: 536 4 1 3 95 66 704 49
|
||||
236503863: 546 954 305 373 131
|
||||
3351192: 2 65 1 640 75 9 78
|
||||
5108625: 3 2 2 5 2 165 313 1 7 8 6
|
||||
178031530140: 14 4 9 269 7 1 710 822
|
||||
6883328: 6 94 1 3 113 7 9 4 1 4 4
|
||||
4007370310: 15 90 8 9 7 357 89 830
|
||||
588964251601: 7 5 347 2 47 20 963 5 1
|
||||
270755048: 6 42 1 631 212 57 8 8
|
||||
1332121: 8 9 8 4 2 3 6 800 8 3 3 88
|
||||
5591335: 371 3 5 2 6 7 5
|
||||
14219565360: 5 993 213 3 8 754 91 5
|
||||
5861562162: 1 8 9 4 8 6 6 4 451 53 6 2
|
||||
1433385: 874 74 21 72 9
|
||||
15707744640: 568 36 6 5 59 434
|
||||
1690128: 66 2 4 97 33
|
||||
398948632: 65 4 61 85 5 3 7 72
|
||||
10387019376: 63 1 245 7 6 77 42 328
|
||||
4179604: 5 6 422 1 20 40 45 4
|
||||
207295515460: 7 423 3 645 7 3 9 6 1 1 9
|
||||
1496054: 80 69 48 12 54
|
||||
117174039: 60 5 5 4 331 59 2 37
|
||||
120561: 443 34 8 3 62
|
||||
1093662: 1 413 9 1 86
|
||||
72832203: 49 3 4 4 791 3 5 22 3 9 9
|
||||
9172450: 520 94 7 264 49 175
|
||||
5092: 9 52 9 6 5 869
|
||||
205017: 859 5 67 47 3
|
||||
502964: 5 465 2 92
|
||||
982872: 55 31 30 94 721 1 6
|
||||
18842130: 997 20 24 362 50 30
|
||||
933: 11 824 8 3 87
|
||||
100362657: 9 3 2 6 375 988 3 3 8 4 1
|
||||
125631197: 7 8 1 2 92 6 9 72 1 563 2
|
||||
16965: 936 759 2 5 8
|
||||
63221509696: 76 214 5 4 340 89 8 8
|
||||
175095120: 66 4 1 5 6 10 184 6 3 8 5
|
||||
5948579768: 69 5 3 2 6 5 44 93 3 8 4 3
|
||||
612455: 6 4 1 638 251 2 8 3 1 9 6
|
||||
35828415: 6 4 1 7 9 779 2 22 5 4 5 7
|
||||
1423570: 77 835 65 4 6 1 849
|
||||
139702935: 55 8 4 5 5 6 4 90 2 935
|
||||
521072: 148 8 55 9 5 8
|
||||
42845205: 9 110 6 54 47 5
|
||||
155790: 8 558 97 18 1
|
||||
347911604818: 91 6 354 22 44 2 9 9 8 8
|
||||
196579: 1 9 15 15 129 2 19 499
|
||||
178336116: 5 53 16 4 522 6 6
|
||||
211784: 352 6 6 22 4
|
||||
357611951: 9 19 8 1 613 463 7 3 3 5
|
||||
2856: 6 31 29 54 4
|
||||
3115653: 8 404 964 5
|
||||
139573401: 1 34 1 142 33 851 891
|
||||
2731: 3 107 8 1 8 8 80 3
|
||||
1635930605522: 8 5 9 6 8 137 7 94 604 2
|
||||
2517747584: 8 1 3 715 424 5 755 1 9
|
||||
13551: 8 9 6 589 4
|
||||
8640: 9 60 9
|
||||
246434062: 6 18 632 93 960 87 62
|
||||
844073: 298 57 899 67 7 47
|
||||
14942463139: 169 883 197 631 39
|
||||
70584888: 8 8 23 8 888
|
||||
66176064187: 882 7 833 5 9 17 2 7 5 3
|
||||
54955: 54 95 5
|
||||
1683752: 417 2 9 562 7
|
||||
31395181: 94 497 1 1 672 9 4
|
||||
418453: 9 7 19 1 1 349 2
|
||||
737204: 8 1 4 189 9 3 86 4 5 5 1 3
|
||||
168
2024/go/day08/day08.go
Normal file
168
2024/go/day08/day08.go
Normal file
@@ -0,0 +1,168 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"adventofcode2024/utils/grid2d"
|
||||
"adventofcode2024/utils/inputs"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type loc struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
type pt struct {
|
||||
display rune
|
||||
antinodes int
|
||||
paired map[loc]pt
|
||||
visited map[rune]bool
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
grid := inputs.ToGrid2D(input, "\n", "", pt{display: '.'}, func(c string) pt { return pt{display: rune(c[0]), paired: make(map[loc]pt), visited: make(map[rune]bool)} })
|
||||
for x1 := 0; x1 < grid.SizeX(); x1++ {
|
||||
for y1 := 0; y1 < grid.SizeY(); y1++ {
|
||||
pt1 := grid.Get(x1, y1)
|
||||
if pt1.display != '.' {
|
||||
for x2 := 0; x2 < grid.SizeX(); x2++ {
|
||||
for y2 := 0; y2 < grid.SizeY(); y2++ {
|
||||
pt2 := grid.Get(x2, y2)
|
||||
if x1 != x2 && y1 != y2 && pt1.display == pt2.display && !isPaired(x1, y1, pt1, pt2) {
|
||||
pt1.paired[loc{x: x2, y: y2}] = pt2
|
||||
pt2.paired[loc{x: x1, y: y1}] = pt1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
pt1 := grid.Get(x, y)
|
||||
if pt1.display != '.' {
|
||||
for ploc := range pt1.paired {
|
||||
addAntiNodes(x, y, ploc.x, ploc.y, grid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
antinodes := 0
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
pt := grid.Get(x, y)
|
||||
if pt.antinodes > 0 {
|
||||
antinodes++
|
||||
}
|
||||
}
|
||||
}
|
||||
return antinodes
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := inputs.ToGrid2D(input, "\n", "", pt{display: '.'}, func(c string) pt { return pt{display: rune(c[0]), paired: make(map[loc]pt), visited: make(map[rune]bool)}})
|
||||
for x1 := 0; x1 < grid.SizeX(); x1++ {
|
||||
for y1 := 0; y1 < grid.SizeY(); y1++ {
|
||||
pt1 := grid.Get(x1, y1)
|
||||
if pt1.display != '.' {
|
||||
for x2 := 0; x2 < grid.SizeX(); x2++ {
|
||||
for y2 := 0; y2 < grid.SizeY(); y2++ {
|
||||
pt2 := grid.Get(x2, y2)
|
||||
if x1 != x2 && y1 != y2 && pt1.display == pt2.display && !isPaired(x1, y1, pt1, pt2) {
|
||||
pt1.paired[loc{x: x2, y: y2}] = pt2
|
||||
pt2.paired[loc{x: x1, y: y1}] = pt1
|
||||
pt1.antinodes++
|
||||
pt2.antinodes++
|
||||
grid.Set(x1, y1, pt1)
|
||||
grid.Set(x2, y2, pt2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
pt1 := grid.Get(x, y)
|
||||
if pt1.display != '.' {
|
||||
for ploc := range pt1.paired {
|
||||
addAntiNodes_p2(pt1.display, x, y, ploc.x, ploc.y, grid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
antinodes := 0
|
||||
fmt.Printf("%v\n", grid.StringWithFormatter(formatter))
|
||||
for x := 0; x < grid.SizeX(); x++ {
|
||||
for y := 0; y < grid.SizeY(); y++ {
|
||||
pt := grid.Get(x, y)
|
||||
if pt.antinodes > 0 {
|
||||
antinodes++
|
||||
} else {
|
||||
if pt.display != '.' { antinodes++ }
|
||||
}
|
||||
}
|
||||
}
|
||||
return antinodes
|
||||
}
|
||||
|
||||
func formatter(p pt, x int, y int) string {
|
||||
if p.antinodes > 0 {
|
||||
return "#"
|
||||
}
|
||||
return "."
|
||||
}
|
||||
|
||||
func isPaired(x int, y int, p1 pt, pt2 pt) bool {
|
||||
return p1.paired[loc{x: x, y: y}].display == pt2.display
|
||||
}
|
||||
|
||||
func addAntiNodes(x1 int, y1 int, x2 int, y2 int, grid *grid2d.Grid[pt]) {
|
||||
px1, py1, px2, py2 := offsetPoints(x1, y1, x2, y2)
|
||||
|
||||
if px1 < 0 || px1 >= grid.SizeX() || py1 < 0 || py1 >= grid.SizeY() {
|
||||
return
|
||||
}
|
||||
pt1 := grid.Get(px1, py1)
|
||||
pt1.antinodes++
|
||||
grid.Set(px1, py1, pt1)
|
||||
if px2 < 0 || px2 >= grid.SizeX() || py2 < 0 || py2 >= grid.SizeY() {
|
||||
return
|
||||
}
|
||||
pt2 := grid.Get(px2, py2)
|
||||
pt2.antinodes++
|
||||
grid.Set(px2, py2, pt2)
|
||||
}
|
||||
|
||||
func addAntiNodes_p2(frequency rune, x1 int, y1 int, x2 int, y2 int, grid *grid2d.Grid[pt]) {
|
||||
px1, py1, px2, py2 := offsetPoints(x1, y1, x2, y2)
|
||||
if !(px1 < 0 || px1 >= grid.SizeX() || py1 < 0 || py1 >= grid.SizeY()) {
|
||||
pt1 := grid.Get(px1, py1)
|
||||
if !pt1.visited[frequency] {
|
||||
pt1.antinodes++
|
||||
pt1.visited[frequency] = true
|
||||
grid.Set(px1, py1, pt1)
|
||||
addAntiNodes_p2(frequency, x1, y1, px1, py1, grid)
|
||||
}
|
||||
}
|
||||
if !(px2 < 0 || px2 >= grid.SizeX() || py2 < 0 || py2 >= grid.SizeY()) {
|
||||
pt2 := grid.Get(px2, py2)
|
||||
if !pt2.visited[frequency] {
|
||||
pt2.antinodes++
|
||||
pt2.visited[frequency] = true
|
||||
grid.Set(px2, py2, pt2)
|
||||
addAntiNodes_p2(frequency, x2, y2, px2, py2, grid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to calculate two points symmetrically placed above and below the line
|
||||
func offsetPoints(x1, y1, x2, y2 int) (int, int, int, int) {
|
||||
dx := x1 - x2
|
||||
dy := y1 - y2
|
||||
|
||||
p1x := x1 + dx
|
||||
p1y := y1 + dy
|
||||
p2x := x2 - dx
|
||||
p2y := y2 - dy
|
||||
return p1x, p1y, p2x, p2y
|
||||
}
|
||||
39
2024/go/day08/day08_test.go
Normal file
39
2024/go/day08/day08_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`............
|
||||
........0...
|
||||
.....0......
|
||||
.......0....
|
||||
....0.......
|
||||
......A.....
|
||||
............
|
||||
............
|
||||
........A...
|
||||
.........A..
|
||||
............
|
||||
............`)
|
||||
require.Equal(t, 14, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`............
|
||||
........0...
|
||||
.....0......
|
||||
.......0....
|
||||
....0.......
|
||||
......A.....
|
||||
............
|
||||
............
|
||||
........A...
|
||||
.........A..
|
||||
............
|
||||
............`)
|
||||
require.Equal(t, 34, r)
|
||||
}
|
||||
50
2024/go/day08/input.txt
Normal file
50
2024/go/day08/input.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
.....y..........................p................r
|
||||
........I.........................................
|
||||
......................4.s.........................
|
||||
..........4.......................................
|
||||
....y.............................................
|
||||
......................................p.........r.
|
||||
..........0..s......N..................1.....p....
|
||||
..y........4.......................p..............
|
||||
...............0..................................
|
||||
..............0....t....N....h....................
|
||||
.............N....................................
|
||||
......j...................s............H...l..O...
|
||||
..........q.................H................O....
|
||||
..f...e.qj.....y...0..............................
|
||||
...........t..........................k..Q..r.....
|
||||
.........6................Q..s...x......W.........
|
||||
....2..b...e....t..4.........c.....xW.j...........
|
||||
...e....................w................1.....O..
|
||||
..e..j..5...........................c.............
|
||||
.........B..2...............MK................H...
|
||||
...2......b...g..X...q..........h...............O.
|
||||
...q...2..........m....k...i...............QV.x...
|
||||
...................i.........W.k.............HQ...
|
||||
........b...X...............D..........c...N......
|
||||
................................l..........h.....I
|
||||
.m...........g......l.......c.............3......V
|
||||
....X.......m........g...V.K...7......F.d.........
|
||||
.........b.X...U..........................C.......
|
||||
.....................l..............o.1....C......
|
||||
............u.............K..............3...d....
|
||||
......................i.T....f................V...
|
||||
..............................1.k.................
|
||||
.B.....E......9..m....K..5.M......................
|
||||
...P...............M...95....o..i........I........
|
||||
...............................S......3......wI...
|
||||
.....EP...........9........5..T.R.................
|
||||
.P..........v..9......f.............R.Co..w3......
|
||||
..........h...SG..v.E...7..f.T....................
|
||||
..........6..........L.................Y.......d..
|
||||
..........B...............U........D..............
|
||||
....B................U.....8..M....n...J..........
|
||||
.........................L................Fw......
|
||||
....L6E.P.................7.UG....J.....Y.D.......
|
||||
........t........v...SJ........n..d...............
|
||||
......................8v.....uG...................
|
||||
..................L.....n.........................
|
||||
...............T..............n......D............
|
||||
..............o.........8................J.Y.R....
|
||||
..................S...............u....F.......R..
|
||||
........6..............u.....7.8..........Y..F....
|
||||
117
2024/go/day09/day09.go
Normal file
117
2024/go/day09/day09.go
Normal file
@@ -0,0 +1,117 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"adventofcode2024/utils"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
disk := []int{}
|
||||
file_id := 0
|
||||
for i := 0; i <= len(input); i++ {
|
||||
for x := 0; x < utils.MustAtoi(string(input[i])); x++ {
|
||||
disk = append(disk, file_id)
|
||||
}
|
||||
i++
|
||||
if i < len(input) {
|
||||
for x := 0; x < utils.MustAtoi(string(input[i])); x++ {
|
||||
disk = append(disk, -1)
|
||||
}
|
||||
}
|
||||
file_id++
|
||||
}
|
||||
|
||||
printDisk(disk)
|
||||
|
||||
for i:=len(disk)-1;i>0;i--{
|
||||
if disk[i] != -1 {
|
||||
id := disk[i]
|
||||
disk[i] = -1
|
||||
for j:=0;j<=len(disk);j++ {
|
||||
if disk[j] == -1 {
|
||||
disk[j] = id
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printDisk(disk)
|
||||
|
||||
checksum := 0
|
||||
for i:=0;i<len(disk);i++ {
|
||||
if disk[i] != -1 {
|
||||
checksum += i * disk[i]
|
||||
}
|
||||
}
|
||||
return checksum
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
disk := []int{}
|
||||
file_id := 0
|
||||
for i := 0; i <= len(input); i++ {
|
||||
for x := 0; x < utils.MustAtoi(string(input[i])); x++ {
|
||||
disk = append(disk, file_id)
|
||||
}
|
||||
i++
|
||||
if i < len(input) {
|
||||
for x := 0; x < utils.MustAtoi(string(input[i])); x++ {
|
||||
disk = append(disk, -1)
|
||||
}
|
||||
}
|
||||
file_id++
|
||||
}
|
||||
|
||||
printDisk(disk)
|
||||
|
||||
for i:=len(disk)-1;i>0;i--{
|
||||
size := 0
|
||||
if disk[i] != -1 {
|
||||
id := disk[i]
|
||||
for {
|
||||
if i-size > 0 && disk[i-size] == id {
|
||||
size++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
free := 0
|
||||
j := 0
|
||||
found := false
|
||||
for ;j<i && free < size;j++{
|
||||
if disk[j] != -1 {
|
||||
free = 0
|
||||
continue
|
||||
}
|
||||
free++
|
||||
if free == size { found = true }
|
||||
}
|
||||
if found {
|
||||
for k:=0;k<size;k++ {
|
||||
disk[i-k] = -1
|
||||
disk[j-size+k] = id
|
||||
}
|
||||
// printDisk(disk)
|
||||
}
|
||||
i -= (size -1)
|
||||
|
||||
}
|
||||
}
|
||||
printDisk(disk)
|
||||
|
||||
checksum := 0
|
||||
for i:=0;i<len(disk);i++ {
|
||||
if disk[i] != -1 {
|
||||
checksum += i * disk[i]
|
||||
}
|
||||
}
|
||||
return checksum}
|
||||
|
||||
func printDisk(disk []int) {
|
||||
for _, x := range disk {
|
||||
if x == -1 {fmt.Print(".")} else {
|
||||
fmt.Printf("%d", x)
|
||||
}
|
||||
}
|
||||
fmt.Print("\n")
|
||||
}
|
||||
17
2024/go/day09/day09_test.go
Normal file
17
2024/go/day09/day09_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1("2333133121414131402")
|
||||
require.Equal(t,1928, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2("2333133121414131402")
|
||||
require.Equal(t, 2858, r)
|
||||
}
|
||||
1
2024/go/day09/input.txt
Normal file
1
2024/go/day09/input.txt
Normal file
File diff suppressed because one or more lines are too long
@@ -13,6 +13,6 @@ require github.com/spf13/pflag v1.0.5 // indirect
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // direct
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user