AdventOfCode2021 - Day 1

This is a thread to discuss Day1
https://adventofcode.com/2021/day/1

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

Good luck :slight_smile:
BTW on of the features of AdventOfCode is that we all get given different inputs so our answers will be different.
The examples are all the same but each of us gets different inputs for us to solve

This is my first successful run at part 1

Part 1

image

duration = 20ms

It is very much NOT the Snap! way do do it but it works :slight_smile:

Hopefully, we'll see some much better solutions :slight_smile:

You'll notice that I set the result to be a list. I do this, so I can easily copy and paste it into the AdventOfCode website

First successful run at part 2

part 2

Duration = 900 ms

Project

Here's my solutions

Part 1


(I had the input on my clipboard)

Part 2

Part 1.
Aoc1-2 script pic

DeltaPlus

Aoc1-2 script pic (1)

Part 2.
Aoc1-2 script pic (5)
Aoc1-2 script pic (3)

slidingSum, forcefully HOF styled

Aoc1-2 script pic (6)

HOF are very impressives ! 40ms VS 1400ms with a loop

Part 1

image
(1050ms with a warp)

image
(60ms)

Part 2

image
(3200ms with a warp)

image
(142ms)

i like all the solutions from everybody!

Can you edit your post to say me how much time it take to execute your code, i'm curious ! (with the big input)

project

I like your method of getting the averages.

I'd forgotten that in Snap! we don't have worry about asking for an item outside of the range of the list.

These look great - completely above my head though :slight_smile:

And you've used recursion on day1 - Brian will like that :slight_smile:

Can you share the link to your project plz

Done
............

Just finished part 1
untitled script pic (1)

Part 1 Solution

Uses Recursion in a variable function so no messy inputs in block
untitled script pic (2)

Done part 2
untitled script pic (3)

Part 2 Solution


Unfortunately kinda slow

project here:Snap! 7 - dev - Build Your Own Blocks