Fork me on GitHub
#adventofcode
<
2020-12-20
>
Vincent Cantin05:12:31

I think I will take the slow path and use insta-image, to learn a few new things.

👍 2
😮 1
euccastro05:12:57

heheh, I took a shortcut for part 1 which is useless for part 2...

1
euccastro05:12:15

now I have all work ahead of me

alekszelark06:12:28

stats so far

20      91   1620  **

👏 4
🤯 2
Vincent Cantin06:12:48

I am still on part1, that’s difficult.

1
rjray06:12:58

I've managed part 1, but also used a math shortcut and now have to start over for part 2.

3
fingertoe08:12:25

Took a few days off — quite a ways into part one of day 20.. Itching to use some datalog..

😱 1
Vincent Cantin08:12:19

If you can do it using Datalog, I will definitely learn something new.

Vincent Cantin08:12:59

Today’s puzzle is an endurance test.

👍 2
Vincent Cantin10:12:40

I don’t see a lot of activity and I wonder if people are still trying to solve the puzzle or if they took a break.

Mno10:12:38

Weekends be like that

Mno10:12:23

In my particular case I'm a bit far behind, and I'm saving a few to warm up for upcoming interviews

euccastro10:12:45

I'm being interrupted a lot, but still soldiering on :)

bananadance 2
euccastro22:12:06

some of my breakthroughs happened during those interruptions, so I can't complain

nbardiuk11:12:59

I've managed to do only part 1 in the morning, will try to finish second part in the evening

Charles Fourdrignier11:12:39

Part 1 was """easy""". But when the part 2 seems having 3 parts, it's a bit terrific.

2
alekszelark13:12:12

Here they go

😂 1
🐍 3
euccastro13:12:27

OK, got the map resolved and stitched, now to look for monsters 😛

👾 2
🦕 1
🐉 1
🐍 1
🐊 1
euccastro14:12:51

found monsters in both the demo and real input, and my dash calculation works for the demo input, but somehow is too high for the real input 😕

benoit15:12:10

I'm skipping this one. It already took me too much time.

euccastro16:12:03

my solution2 function is really monstrous, keeping with the challenge theme, but https://github.com/Saikyun/miracle.save made it relatively easy to debug. It lets you work as if the definitions in the local let were module-level (so you can just evaluate forms inside the function). https://github.com/vvvvalvalval/scope-capture is a more powerful alternative, but I find it harder to remember how to use it

misha16:12:28

@vincent.cantin why do you have only 4+4 card variants? are you flipping only vertically? I got 16:

misha16:12:50

(defn flip [s] (-> s reverse str/join))

(defn flip-hor [[t r b l]] [(flip t) l (flip b) r])
(defn flip-ver [[t r b l]] [b (flip r) t (flip l)])
(defn turn-lef [[t r b l]] [r b l t])
(defn turn-rig [[t r b l]] [l t r b])

(def mops
  (->>
    [flip-hor flip-ver turn-lef turn-rig]
    (map memoize)
    (apply juxt)))


(defn transformations [edges]
  (->> #{edges}
    (iterate (fn [variants]
               (->> variants
                 (map mops)
                 (reduce into variants))))
    (partition 2)
    (drop-while #(apply not= %))
    (ffirst)))
(def edges ["...#.#.#.#" "#..#......" ".#....####" "#.##...##."])
(->> edges transformations)
=>
#{["#.#.#.#..." "......#..#" "####....#." ".##...##.#"]
  [".#....####" "#.##...##." "...#.#.#.#" "#..#......"]
  ["#.#.#.#..." "#.##...##." "####....#." "#..#......"]
  ["......#..#" "...#.#.#.#" ".##...##.#" ".#....####"]
  ["#.##...##." "...#.#.#.#" "#..#......" ".#....####"]
  ["####....#." "#..#......" "#.#.#.#..." "#.##...##."]
  ["####....#." ".##...##.#" "#.#.#.#..." "......#..#"]
  ["...#.#.#.#" ".##...##.#" ".#....####" "......#..#"]
  [".#....####" "......#..#" "...#.#.#.#" ".##...##.#"]
  ["#..#......" ".#....####" "#.##...##." "...#.#.#.#"]
  ["......#..#" "####....#." ".##...##.#" "#.#.#.#..."]
  ["...#.#.#.#" "#..#......" ".#....####" "#.##...##."]
  ["#.##...##." "####....#." "#..#......" "#.#.#.#..."]
  ["#..#......" "#.#.#.#..." "#.##...##." "####....#."]
  [".##...##.#" ".#....####" "......#..#" "...#.#.#.#"]
  [".##...##.#" "#.#.#.#..." "......#..#" "####....#."]}

alekszelark16:12:45

that’s enough to check

alekszelark17:12:52

First you rotate a piece (4 times), it’s not matched, you flip it and do rotation again (+ 4). That’s all possible combinations.

alekszelark17:12:12

Doesn’t matter how you flip it vertically or horizontally.

misha17:12:10

all possible are shown above: 16, no?

misha17:12:53

(admittedly, those are after multiple manipulations)

misha17:12:30

unless rotated and flipped to a random orientation. means "rotated once then flipped once", and not "rotated, flipped, rotated again, flipped again.. etc"

alekszelark17:12:46

(def tile [[1 2 3]
           [3 4 5]
           [6 7 9]])

(take 4 (iterate rotate tile))

([[1 2 3]
  [3 4 5]
  [6 7 9]]
 
 [[6 3 1]
  [7 4 2]
  [9 5 3]]
 
 [[9 7 6]
  [5 4 3]
  [3 2 1]]
 
 [[3 5 9]
  [2 4 7]
  [1 3 6]])

(take 4 (iterate rotate (flip tile)))

([[6 7 9]
  [3 4 5]
  [1 2 3]]
 
 [[1 3 6]
  [2 4 7]
  [3 5 9]]
 
 [[3 2 1]
  [5 4 3]
  [9 7 6]]
 
 [[9 5 3]
  [7 4 2]
  [6 3 1]])

peterc17:12:13

You can pick up a piece of paper and see there are only 8 orientations

👍 1
alekszelark17:12:13

Even better you can pick up a real puzzle piece

nbardiuk18:12:18

I also had doubts, but then called a set an all flips and rotations and it was just 8

misha18:12:11

my set has 16 d

misha18:12:36

anyway, it seems like 1 flip + 1 rotation

markw18:12:46

@misha unlikely it’s your problem, but I also had 16 at first… I was adding back the original, unmodified grid at the end, and forgot to wrap it in [] when concatting with the list of rotation/flips, which added each individual row (rookie mistake I know)

markw18:12:51

also, I think taking the set of rotations/flips will result in a variable number, since sometimes there is symmetry in the input. For example flipping: [["*" " " " "] ["*" "*" "*"] ["*" " " " "]] the top-bottom rotations will be the same.

Joe18:12:41

If you have the 8 basic symmetries of a square (4x rotational, 4x reflection), then any combination of these of the operations can be simplified to any of the basic 8.

misha19:12:22

found it:

(defn flip-hor [[t r b l]] [(flip t) l (flip b) r])
(defn flip-ver [[t r b l]] [b (flip r) t (flip l)])
(defn turn-lef [[t r b l]] [r b l t])
(defn turn-rig [[t r b l]] [l t r b])
->>
(defn flip-hor [[t r b l]] [(flip t) l (flip b) r])
(defn flip-ver [[t r b l]] [b (flip r) t (flip l)])
(defn turn-lef [[t r b l]] [r (flip b) l (flip t)])
(defn turn-rig [[t r b l]] [(flip l) t (flip r) b])
harold

💥 1
🍾 1
euccastro22:12:03

madness dot png

euccastro22:12:04

here I was trying to convince myself that I could do with just flips and transposes (i.e., no need for explicit rotations). I was silly/underslept enough to clutter the drawing with arrows in both directions even though all basic ops are their own inverses

euccastro22:12:39

@U5P5Z5J23 there is no symmetry in the puzzle tiles; all borders are unique, even allowing for reversals

markw22:12:32

Yeah after much banging my head against the wall I came to the same conclusion.. and now I’m stuck

markw22:12:49

every square unique, every perimeter unique, every convolved perimeter unique.. .ugh

markw22:12:12

and 8^144 choices 😕

alekszelark17:12:19

Did a visualization of part 2

🎨 9
🦕 1
❤️ 1
Alexandre Grison10:12:53

Did one also, except I solved this one with Kotlin 😄

😁 1
Joe18:12:19

Wow, I think I hit the wall on this one. End of the AOC adventure for me this year 😞

❤️ 5
🙌 1
goberserk 2
nbardiuk18:12:21

today was really work for 2 different days. Assembling jigsaw puzzle and pattern matching are different problems. I wrote 2x code compared to the longest previous day

euccastro22:12:51

For me, assembling the puzzle alone was work for 2 days. once that was done, scanning for monsters felt relatively straightforward