AdventOfCode2021 - Day 3

This is a thread to discuss Day3
https://adventofcode.com/2021/day/3

REMEMBER!
It is VERY important NOT to write any public spoilers :slight_smile:
ALWAYS keep spoiler stuff hidden inside one of these

Summary

This text will be hidden

which you can obtain by clicking on the gear icon

image

This is my first successful run at part 1

duration = 25 ms

I couldn't find (in my own library) a binary -> decimal convertor so just coded an inline one up.
I've definitely used one in the past (copied from one Brian made) but for some reason forgot to save it and stick it in my local useful library blocks

Part 2 (see project for details)

duration = 140 ms

Project

Here's my solutions

Part 1




(I didn't want to bother creating a binary to decimal convertor)

Part 2



Project
Snap! 6.9.2 Build Your Own Blocks (in the day 3 scene)
edit: I think snap saves the current scene you're on in the project.

Oh! the part 2 was not easy to understand for me (i speak french you remember...), i will try it tomorrow...

I liked the way you did epsilon in Part 1 - much better than mine

And lovely recursion in Part 2 :slight_smile:

I knew how to do part 2, it's just putting it to code was a lot harder. I also knew I was gonna do recursion from the start, so I made it with you know, recursion in mind.

Part 1 -> 47ms

Part 2 -> 7.7 sec (not efficient)


image

project

Part1

Aoc script pic (5)

Part2

Aoc script pic (3)
Aoc script pic (4)

ok part 2 done ngl this was so hard

Part 1

untitled script pic (8)


forgot warp on bin 2 dec, but its super fast with it

Part 2


I had to use recursion but i made one script to handle both tasks, hows that for not wasting code, its also very fast, even without the warp