adventofcode

Dos 2020-12-05T09:11:34.288400Z

@dos has joined the channel

Aleks 2020-12-05T09:47:50.289300Z

I solved it literally how it says (spoiler) ๐Ÿ˜ž

โ˜๏ธ 1
Aleks 2020-12-05T09:48:15.289400Z

(defn decode [lo hi s]
  (if-let [c (first s)]
    (case c
      (\F \L) (recur lo (+ lo (quot (- hi lo) 2)) (next s))
      (\B \R) (recur (+ lo (inc (quot (- hi lo) 2))) hi (next s)))
    lo))

๐Ÿ‘ 1
Aleks 2020-12-05T11:09:51.294300Z

And my final decode

(defn decode [code]
  (-> (str/escape code {\F 0 \L 0 \B 1 \R 1})
      (Long/parseLong 2)))

๐Ÿ’ฏ 3
nbardiuk 2020-12-05T12:04:16.294700Z

Cool! escape another function I've learned today

๐Ÿ‘ 2
plexus 2020-12-05T12:21:56.295600Z

Ooh that's a good one! Sequestering it for my toolbox :) ๐Ÿงฐ

๐Ÿ˜ 1
โ˜๏ธ 1
pez 2020-12-05T14:22:34.298300Z

I did it even more literally. ๐Ÿ˜ƒ I figured while doing it that there must be another way, but the thing with gold stars is that they give me fever and make me indifferent to what happens to gnomes and kittens.

1
โ˜๏ธ 2
๐Ÿคฉ 1
2020-12-05T11:46:33.294600Z

@dans44684 has joined the channel

james 2020-12-05T12:04:36.295Z

@johsgrd has joined the channel

2020-12-05T14:47:38.299700Z

@kevin.van.rooijen has joined the channel

shidima 2020-12-05T15:14:27.299900Z

@shidima has joined the channel

aglassman 2020-12-05T18:49:12.304900Z

@aglassman has joined the channel

andrea 2020-12-05T20:52:08.307100Z

@andrea has joined the channel

Sam Adams 2020-12-05T22:02:12.307800Z

@sam.h.adams has joined the channel

R.A. Porter 2020-12-05T04:57:08.267800Z

@coyotesqrl has joined the channel

2020-12-05T05:27:46.268200Z

Good morning

๐Ÿ‘‹ 5
fingertoe 2020-12-05T05:51:50.269900Z

Day 5 probably would have been a lot easier if I had carefully read the problem.. Not too bad though..

rjray 2020-12-05T05:52:00.270100Z

Day 5 done. I found the wording of part 2 to be very confusing. Lost time trying to figure out WTF was being asked for. Once I understood, the solution was pretty simple.

2020-12-05T06:16:40.275100Z

My cat started screaming right at that time, making it very difficult to focus on the problem. ๐Ÿ“ memo: take the cat away for tomorrowโ€™s puzzle.

mchampine 2020-12-05T06:02:48.274600Z

Agreed, the wording of part 2 took a while to interpret. I thought the description in part one was also a very long winded way to describe binary that could easily lead someone down a very long unproductive path. I suspect that was intentional and that youโ€™re supposed to be rewarded (with time savings) for insights that lead to dramatically simpler solutions. Iโ€™m pretty happy with my 6 line solution to part 1. Part 2 took another 2 lines but is slightly hacky. Looking forward to seeing other approaches.

2020-12-05T06:18:41.276300Z

I solved part2 before I had a correct expression to solve it, just by doing some data exploration โ€ฆ the solution appeared clearly in the middle of false positives.

erwinrooijakkers 2020-12-05T06:42:01.281300Z

Good morning. Probably can be done nicer using an index instead of a vector representation but itโ€™s Saturday. I hope to see an example with index later today ๐Ÿ™‚ https://github.com/transducer/adventofcode/blob/master/src/adventofcode/2020/day5.clj

nbardiuk 2020-12-05T06:53:24.282300Z

https://github.com/nbardiuk/adventofcode/blob/master/2020/src/day05.clj spoiler ๐Ÿ‘‡

๐Ÿ‘ 5
tschady 2020-12-05T10:21:43.290900Z

i prefer (Integer/parseInt s 2) to read-string tricks, but that might be personality.

โž• 1
Aleks 2020-12-05T10:32:07.292Z

Me too, but the better way to do that is to use Long/parseLong . Ultimately, all the numbers in Clojure represented as Longs.

Aleks 2020-12-05T10:57:39.293600Z

@nbardiuk Just realized from your solution, that splitting at row and col and then some math are not needed at all.

๐Ÿ‘ 1
Aleks 2020-12-05T10:58:19.293900Z

I should carefully look at the input data.

plexus 2020-12-05T12:20:01.295400Z

Yeah I thought I was pretty smart by spotting it was just binary, but now I feel silly for not realizing that row+col are just a single number, no need to split them up :)

๐Ÿ˜ฒ 1
โž• 1
tschady 2020-12-05T12:25:27.295800Z

* 8 was the clue. Why 8?

Aleks 2020-12-05T12:30:41.296Z

Itโ€™s a power of 2. 2 2 2 = 8. Multiplying by 2 means the same thing you do with shift-left. For example

(= (bit-shift-left 1 3)
   (* 1 8))

Aleks 2020-12-05T12:32:32.296200Z

and then just bit-or itโ€™s binary addition, so you get the same result just by decoding a whole string.

erwinrooijakkers 2020-12-05T13:07:40.296500Z

Thatโ€™s it yes

erwinrooijakkers 2020-12-05T13:07:51.296700Z

Missed it ๐Ÿ™‚

erwinrooijakkers 2020-12-05T13:08:04.296900Z

Jonathan did same: https://www.youtube.com/watch?v=wa0VcQugEsI

woonki.moon 2020-12-05T13:27:02.297900Z

how brilliant!

erwinrooijakkers 2020-12-05T14:25:55.298500Z

row and col are just a single number?

erwinrooijakkers 2020-12-05T14:26:15.298700Z

because of adding?

erwinrooijakkers 2020-12-05T14:26:16.298900Z

ah

erwinrooijakkers 2020-12-05T14:26:35.299100Z

wow

erwinrooijakkers 2020-12-05T14:43:25.299300Z

So ๐Ÿ™‚ For example โ€œBFFFBBFRRRโ€ is in binary 1000110 111, so:

(+ (* 8 (Integer/parseInt "1000110" 2))
   (Integer/parseInt "111" 2))
;; => 567
which is equal to:
(Integer/parseInt "1000110111" 2) ;; => 567 

๐Ÿคฏ 1
2020-12-05T19:08:28.306700Z

I feel dumb. I created a range from 0 to 127 and recursively either drop / take half of it.

nbardiuk 2020-12-05T06:53:54.282600Z

seat number is just a binary with 0 and 1 replaced with L|F and R|B

2020-12-05T06:58:07.282900Z

another trick is how to parse it โ€ฆ there is a clojure function for that

๐Ÿค” 1
dpkp 2020-12-05T07:04:47.283300Z

Very nice

nbardiuk 2020-12-05T07:07:35.283600Z

@vincent.cantin cannot find anything suitable, I am very intrigued ๐Ÿ˜ฎ

nbardiuk 2020-12-05T07:12:59.285300Z

oh cool! learn something new with every puzzle ๐Ÿ˜†

plexus 2020-12-05T07:17:37.285800Z

I guess I'm the only one who actually bothered to use bit-shift/bit-or ๐Ÿ™‚

๐Ÿ™‚ 1
2020-12-05T07:18:28.286Z

edn/read-string is a good parser

2020-12-05T07:20:24.286600Z

@plexus I like your approach for part2

plexus 2020-12-05T07:21:16.286900Z

the (partition coll n 1) trick has saved me more than once

erwinrooijakkers 2020-12-07T11:31:15.361300Z

Me too 45 minutes of fighting with off-by-one errors and nullpointerexceptions ๐Ÿ™‚

plexus 2020-12-05T07:46:33.287600Z

Today's video: https://youtu.be/eNMJH_GZld0

๐Ÿ‘ 5
nbardiuk 2020-12-05T09:06:34.288Z

I didn't know about step argument in partition-all . Literally yesterday had to implement the pairs function manually

andrea 2020-12-05T20:59:30.307300Z

Nice! @plexus any info about your env setup? Is that vim plus what?

plexus 2020-12-06T05:31:51.310100Z

https://github.com/plexus/corgi

plexus 2020-12-06T05:33:51.310800Z

Planning to get that to a shippable state during the christmas/new years holidays

๐Ÿ‘ 1