#Advent of Code 2023

1 messages ยท Page 3 of 1

jaunty hawk
#

not difficult, except debugging the x position checker was a pain since i'm not good at visualizing those things and kept flipping the signs

#

it took a while

stray violet
#

mine was very oop-y

jaunty hawk
#

i barely know how to oop

#

i avoid it when possible and just used nested lists

#

by nested i mean

#

Very Nested

stray violet
jaunty hawk
stray violet
#

that would be unbearable without comments jeez

I mean if it works if it works

jaunty hawk
#

it used to be entirely uncommented

#

i always had like 2 screen long keys at the top of my program to let me know what indexes of what lists and sublists and subsublists meant what thing

#

other than that i had virtually no comments

#

the third screenshot was after i returned to the project a month later and was like "huh. um. what is this code for"

stray violet
#

need to be proactive and start on the hour

hazy abyss
stray violet
#

oh noooo I almost lost track of time

#

gotta be prompt

#

gogogo

#

I think this one ended up being my shortest code of the 4 days

quiet frigate
#

oh today looks pretty easy

jaunty hawk
#

you know what, i have time, i'll see if i can do this one today

#

actually nah i'm tired i'll do it tomorrow maybe

severe flame
#

why is it so all over the place

#

one day easy one day hard

#

lol

quiet frigate
#

tree shaking

#

or something

#

anyways, || everytime I try to use regex I remember I don't know regex ||

#

||Should I have bought that regex book at the bookstore...? Probably...||

ripe lance
#

okay i think ill like this one a lot more

fickle hornet
#

fucking hell reading comprehension is hard, I took so long to realise the change in how scoring is calculated

ripe lance
#

||points *= 2||

fickle hornet
#

||I meant the part change, pt1 -> pt2||

ripe lance
#

oh lol

#

sry

#

i just woke up from a killer nap

#

ill get started on it in a bit

fickle hornet
#

||>the change in how scoring is calculated||

#

Day04 should be easy to do in bash, at least looking at the input and how I did it

stray violet
#

I had failed to account for ||cascading copies|| the first time I did part 2

fickle hornet
#

Me too kinda, at first I didn't fail to account for them, I just completely failed to grasp how to implement them at first, ||I tried to implement a running multiplier at first... a vector was so much better||

bold coral
#

eats this fake quote

spiral zinc
#

this was a nice break after the last couple days lol

fickle hornet
bold coral
#

casually winning millions of scratch cards

#

๐Ÿ’€

#

when you wake up an hour earlier but the puzzle is so easy that you're lower same rank than yesterday

#

also day 3 is completely broken on windows??

#

giving completely different results

#

wild

ripe lance
#

aay first try

bold coral
#

pog

ripe lance
#

i think ill take a break bc part two seems a little confusing

bold coral
#

checked the stats page
apparently only 43 people have solved day 23 part 2 of AOC 2015

slate zephyr
#

I solved today's part 1 on a school computer but I can't log in so I can't see part 2 :(

#

(I used nom! I feel the brain wrinkles forming)

bold coral
#

un-wrinkles your brain

#

:(

#

no wrinkles

#

bad manners

slate zephyr
#

Nooo my knowleegeee

bold coral
#

shlrop

tidal girder
#

gold is the amount of people who have solved both

#

silver is the amount of people who have solved just part 1

bold coral
#

oh wait

#

yea

real robin
#

aoc done for today

#

my solution is great and horrible at the same time

#

for part 2

#

part 1 was fine

#

||```rust
use std::collections::HashMap;

fn main() {
let input = include_str!("input.txt");
let result = calculate(input);
println!("result: {}", result);
}

fn calculate(input: &str) -> i32 {
let cards = input.lines();

let mut card_counts: HashMap<i32, i32> = HashMap::new();

for i in 1..(cards.clone().count() + 1) {
    card_counts.insert(i as i32, 1);
}

let total: i32 = cards
    .map(|card| {
        if let Some((card_info, numbers)) = card.split_once(":") {
            let card_id = card_info
                .split_whitespace()
                .last()
                .unwrap()
                .parse::<i32>()
                .unwrap();
            if let Some((winning_numbers_str, numbers_str)) = numbers.split_once("|") {
                let winning_numbers = winning_numbers_str
                    .split_whitespace()
                    .collect::<Vec<&str>>();
                let numbers = numbers_str.split_whitespace().collect::<Vec<&str>>();

                let no_winning_cards: i32 = winning_numbers
                    .iter()
                    .map(|winning_num| numbers.contains(&winning_num) as i32)
                    .sum();

                for i in (card_id + 1)..(card_id + 1 + no_winning_cards) {
                    if let Some(future_count) = card_counts.get(&i) {
                        if let Some(current_count) = card_counts.get(&card_id) {
                            card_counts.insert(i, future_count + current_count);
                        } else {
                            card_counts.insert(i, future_count + 1);
                        }
                    } else {
                        card_counts.insert(i, 1);
                    }
                }
            }
        }
        return 0;
    })
    .sum();

let total: i32 = card_counts.iter().map(|(_, v)| v).sum();

return total;

}

#

the map needs the .sum() on the end so that it actually runs the stuff in the closure ๐Ÿ˜ญ

bold coral
#

you can also do .for_each?

#

or just .. for card in cards

#

no sense making an iterator if you're not actually using it

real robin
#

yeah i did actually use it in part 1

#

and i was like "oh part 2 is just a tiny modification on part 1"

#

so i copy pasted and then it ended up not being useful

bold coral
#

I'm gonna stab your nan if you don't remove that useless sum

#

:C

real robin
#

hahahaha

#

rip to my nan i guess

real robin
bold coral
#

๐Ÿ”ซ๐Ÿ›๐Ÿ”ช

#

my assassin bug is on its way to your grandmother

hazy abyss
bold coral
#

.collect::<Result<_, _>>().unwrap()

hazy abyss
#

what's the issue? mhuahah

bold coral
#

I'm uh

#

i'm killing you

#

I'm stabbing you

#

I'm disrespecting you

#

:3

hazy abyss
#

:3

#

amen

bold coral
#

I'm stealing your lunch

hazy abyss
#

though there wasn't really any other way to unwrap apart from doing it inside the map, which would arguably be more ugly

bold coral
#

yea it's not actually bad I just wanna annoy you :x

#

||the 1 case is superfluous, no?||

#

2.pow(1-1) == 1

hazy abyss
#

1 * 2 * 2 * 2
4 - 1 = 3
2 ^ 3

#

1 * 2 * 2 * 2 == 2 ^ 3

#

checks out

bold coral
#

what?

hazy abyss
#

last time I tried doing just 2_usize.pow(n.saturating_sub(1) as u32) and it didn't work so I'm trying to not do that again

bold coral
#

well yea, cuz that's wrong

#

the 0-case is important

#

but the 1-case isn't

#

because your n => and 1 => are the same

hazy abyss
#

yes yes

#

(winning_numbers_gotten != 0).then(|| 2_usize.pow(n as u32 - 1)).unwrap_or_default()

bold coral
#

ew

#

I mean just rust let points = match winning_numbers_gotten { 0 => 0, n => 2_usize.pow(n as u32 - 1), };

hazy abyss
#

yeah I changed it to that already

bold coral
#

bites you

hazy abyss
#

it's just I thought it was funny

loud vale
#

holy shit part two made me doubt myself for like 30 minutes. like no way the answer is ||over 18.5 million||, there has to be something wrong with my math right

bold coral
#

kek

#

I had the same reaction

#

then I just tried it and it worked

loud vale
#

i put it in just to see how far it was out and almost got whiplash when it was like "that's right, well done!" floof_think

bold coral
#

tru

hazy abyss
#

yeah part 2 is very exponential

loud vale
#

The weirdest part was looking at the exponential counts resetting every now and then and thinking I'd screwed up a loop or something.

hazy abyss
#

oh very interesting

bold coral
#

I got confused for a while cuz I forgot you already had one of each card

hazy abyss
#

i completely messed it up initially

real robin
#

yeah it's a pretty cool stochastic process

loud vale
#

At least my code is aesthetic ๐Ÿ™ƒ

real robin
loud vale
#

I love doing that. It's the programming version of "kindly disregard my previous email".

hazy abyss
#

todo!()

#

very useful

real robin
#

literally dbg!() everywhere being like wtf is happening

loud vale
#

One of the things I've been trying to achieve while going through this year is building solutions that are robust enough to support the answer for part 1 and 2 of the puzzle. This one I'm particularly chuffed about.

||```typescript
type Card = {
card_number: number;
winning_numbers: number[];
uncovered_numbers: number[];
matching_numbers: number;
};

const parse_game = (line: string): Card => {
const [card, numbers] = line.split(":").map((chunk) => chunk.trim());
const card_number = parseInt(card.trim().split(" ").at(-1)!);

const [winning_numbers, uncovered_numbers] = numbers.split("|").map((chunk) =>
chunk
.split(" ")
.filter((v) => v.trim())
.map(Number),
);

const matching_numbers = winning_numbers.filter((num) =>
uncovered_numbers.includes(num),
).length;

return {
card_number,
winning_numbers,
uncovered_numbers,
matching_numbers,
};
};

export const Puzzle1 = (lines: string[]) => {
// Convert the lines of the record to a Game object.
const cards: Card[] = lines.map(parse_game);

// Find all the lines that have wins, and calculate the totals.
const card_wins = cards.reduce(
(score, card) =>
card.matching_numbers == 0
? score
: score + Math.pow(2, card.matching_numbers - 1),
0,
);

return card_wins;
};

export const Puzzle2 = (lines: string[]) => {
// Convert the lines of the record to a Game object.
const cards: Card[] = lines.map(parse_game);

const cards_won: { [card_index: number]: number } = Object.fromEntries(
cards.map((card) => [card.card_number, 1]),
);

// Find all the lines that have wins, and calculate the totals.
for (const card of cards) {
if (card.matching_numbers == 0) continue;
const copies = cards_won[card.card_number];

for (const card_number of range(
  card.card_number + 1,
  card.card_number + card.matching_numbers,
)) {
  if (card_number in cards_won) {
    cards_won[card_number] += copies;
  }
}

}

// console.log(
// Object.fromEntries(
// Object.entries(cards_won).map(([card_number, count]) => [
// Card ${card_number},
// count,
// ]),
// ),
// );

return Object.values(cards_won).reduce((sum, curr) => sum + curr, 0);
};

bold coral
#

.map(Number)?

#

what's Number

#

Oh

#

JavaScript lmfao

loud vale
#

I'm being a hack and writing them in js/ts first lol

slate zephyr
real robin
#

yeah nice and easy one today

jaunty hawk
#

gonna do this one today with some spare time

#

part 1 completed in 8 minutes

bold coral
#

yea part 1 is pretty nice

#

part 1's difficulty should be swapped with day 1 part 2 lol

jaunty hawk
#

part 2 is a bit trickier especially since i am having difficulty parsing the instructions

hazy abyss
#

yeah the step by step for it is REALLY helpful

spiral zinc
#

yeah i couldn't really parse the description until i started trying to implement it

hazy abyss
#

I'm really happy with my solution for it, it's so neat even if it did have to use a collection

#

actually i could sort of fix that...

spiral zinc
#

what collection? i feel like you only need arrays, as long as you know the input length

hazy abyss
#

well that's the issue ain't it

#

||I used a BTreeMap||

hazy abyss
slate zephyr
hazy abyss
#

it's faster on smaller collections

#

also

slate zephyr
#

But don't you need to iterate on all of them regardless?

hazy abyss
#

this new solution keeps the size at a minimum

jaunty hawk
#

part 2 is surprisingly tricky

hazy abyss
#

but all of them might be something else

stray violet
#

just gotta be careful with copies that induce other copies

slate zephyr
#

Here's how I dealt with it: (spoilers for both parts)
||```rs
//I parsed everything into this struct (with nom):
struct Card {
id: i32,
winning_nums: Vec<i32>,
gotten_nums: Vec<i32>,
}

// Part 1
let fin = cards.into_iter().map(|card| {
card.gotten_nums.into_iter().fold(0, |acc, num| if card.winning_nums.contains(&num) {acc + 1} else {acc})
})
.filter(|v| v != &0)
.fold(0, |acc, cnt| acc + 2i32.pow(cnt - 1));

//Part 2
let mut result = vec![1; cards[cards.len() - 1].id as usize + 1]; // One indexed, just ignore 0
for card in cards {
let mut cnt = 0;
for gotten in card.gotten_nums {
if card.winning_nums.contains(&gotten) { cnt += 1; }
}
for dx in 1..=cnt {
result[card.id as usize + dx] += result[card.id as usize];
}
}

hazy abyss
slate zephyr
#

Do you remove the prints for benchmarking?

hazy abyss
#

no

#

because then the entire problem can be optimized out

slate zephyr
#

ah alr

#

I'm running that exact command then

spiral zinc
hazy abyss
#

i guess it's just more easily optimizable

#

also I'm only testing part 2

#

with a hashmap it's very slightly faster

#

BTreeSet also seems to be a tiny tiny bit slower for the winning number collection ๐Ÿ˜”

slate zephyr
#

part_2

hazy abyss
#

whoops

#

forgot to rebuild

#

part 1

bold coral
#

smh

jaunty hawk
#

my part 2 code is finally no longer crashing and visually working, but is taking a Long time to process

#

either i coded it EXTREMELY badly and accidentally made an exponential process, or i have made incredibly poorly optimized code

#

it has been running for a full minute despite my previous days taking milliseconds

#

to do some debugging i made a simple debug thing and there are currently over 20,000 cards

#

can someone tell me whether this is too many so i don't have to wait seventeen years only to discover it has failed

slate zephyr
#

Iirc my result was around half a million

jaunty hawk
#

yike!!!!! that is a lot of processing time

#

time to optimize this code

slate zephyr
hazy abyss
#

can't compare on different machines

#

though I have made it faster

slate zephyr
#

It's over double my speed if it's both parts lmao

hazy abyss
#

with capacity set for the hashmap

#

kid of weird

#

lemme close firefox

stray violet
jaunty hawk
#

nah, it's kinda ugly, and i think it's working, i'll just wait a while

hazy abyss
#

kinda funny how closing firefox improved the outliers by only like 20 microseconds

#

need the scooby doo meme here

slate zephyr
#

Which one?

hazy abyss
slate zephyr
#

lmao

jaunty hawk
#

well i mad eit run much faster by storing what each card requests to add to the end of the list

#

however!

#

wait what no way is that the right answer

#

processing took 25 seconds and 665 milliseconds

#

let's see how fast it runs without printing (python takes ages to print)

#

wow!!! only 6 seconds

#

blazing fast

hazy abyss
#

that's crazy

slate zephyr
#

It's so succint

#

I wish mine was half as beautiful as that lmao

hazy abyss
#

the regex is so unnecessary but the rest is cool

#

it would be way easy to use a function then a array for that

#

or well, faster

#

though idk actually

slate zephyr
#

Man, that looks so elegant

#

I'm going to try 2022, Day 1, to learn how to parse better

hazy abyss
#

๐ŸŒฒ Participate in Advent of Code 2023 using Kotlin and win prizes! Read more โžค https://kotl.in/AoC23
This year, over the first 12 days of December, weโ€™ll hold livestreams every day to walk through the puzzle of the day together, discuss possible approaches and solutions, and chat with guests from the Kotlin team and the community.

Advent of C...

โ–ถ Play video
severe flame
#

meow

stray violet
#

what on EARTH

severe flame
#

I am so stuck hoyl fuck

stray violet
#

got something but it's SLOW

severe flame
#

I think me too

quiet frigate
#

Ughhh been busy yesterday and today and I'm already behind :(

stray violet
#

ohg od moh god my cpu

#

why don't you like this

#

maybe I should use iterators instead?

stray violet
#

ok yeah I'm so done with part 2

#

how.

severe flame
#

I think I got it but it's a n^4 solution

#

lmao

stray violet
#

where n is?

severe flame
#

the number of seeds

stray violet
#

jesus

severe flame
#

I am waiting for it to compute

#

lmao

#

it's gonna take a while

#

I expect it to take 5-10 minutes

#

I will go see others people solutions while it computes

#

I am curious how much smarter other people are

stray violet
#

I do not have the luxury of being able to do that without my computer dying

severe flame
#

oof

stray violet
#

okay okay we're getting ther

#

tqdm my beloved

severe flame
#

I quit on part 2 I think

#

a lot of people say they solved part 2 with pen and paper but my brain is too stupid to grasp how

#

it's too punishing to make a small mistake

#

just straight up having a staring contest with the executable

#

it's frustrating

stray violet
#

I have an idea but it's not entirely fleshed out

#

mayve in the time I figure it out my shittycode might finish

(edit: ran out of memory)

severe flame
#

oof

#

yeah I give up on part 2

quiet frigate
#

So... I guess I'm going to cry?

stray violet
#

I realize I will probably not be able to do aoc on my travels jsut because I talk my reasoning out loud

#

and like

#

I don't need to say any more

quiet frigate
#

Oh hey good to know I'm not the only one that does that

#

Do you also not have much of an internal monologue?

severe flame
#

I edited the code

#

to fix what I had wrong

#

and it took 6 minutes to do 1 seed

#

this isn't workig

stray violet
#

I am going to try something but I have no idea how long it'll take

stray violet
quiet frigate
#

You can train it???

stray violet
#

idk

#

anyway

#

I think I'm on somewhat of the right track

#

๐Ÿ™

#

I've gone from "code that will get the right answer but also fry my computer" to "code that will get the right answer and is not too memory taxing but still really slow"

IT FINISHED ๐Ÿ˜ฒ

quiet frigate
#

Wondering if these puzzles get too hard I just do the previous years lmao

bold coral
#

๐Ÿ˜ตโ€๐Ÿ’ซ

bold coral
#

ok the input looks real hard but implementing was actually p easy

spiral zinc
#

part 1?

bold coral
#

yea

#

doing part 2 now

spiral zinc
#

i think this is the first day i'm going to have to ||rewrite my entire solution for part 2||

bold coral
#

looks at part 2

#

oh no

spiral zinc
#

:)))))

bold coral
spiral zinc
#

i'm not giving up on uiua just yet but this is gonna be hard

bold coral
#

the tricky part is that ||I'll have to split the ranges if they're not entirely in the mapping||, yea?

spiral zinc
#

yeah

bold coral
#

hm

#

h m m m m m

spiral zinc
#

really just ||working with these ranges in general|| feels like it's going to be a pain

bold coral
#

ok no I think I know how

#

gonna go to the bathroom and hope I don't forget before I can implement

spiral zinc
#

gonna have to draw out some examples i think

bold coral
#

You or me?

spiral zinc
#

me

spiral zinc
#

okay yeah the overlap calculations aren't that bad

loud vale
#

The overlap calc was easy, but I'm hurting trying to figure out how to do that a bajillion times now ๐Ÿ™ƒ

fickle hornet
#

where does my overlap calc fuck up AAAAAAAAAAAAAA

spiral zinc
#

have you considered the case where the sets are completely disjoint?

#

anyway i think i have a uiua-friendly algorithm for part 2 now, just need to actually implement it lol

spiral zinc
fickle hornet
#

fuck, now my overlap calc gives the same example output with the example input but it doesn't give expected output with my input

bold coral
#

I'm dying

#

:3

fickle hornet
#

4.5h spent on this, nah, need sleep now, overlap calc too fucky, why do I have an endless loop somewhere

bold coral
#

the absolute struggle

hazy abyss
#

the great filter

bold coral
#

i am still fighting

#

I just noticed I missed lunch

#

and only now realized I've spent my entire work day so far on this

tired belfry
bold coral
#

5000 more people solved it in the meantime

bold coral
#

hey

#

wouldn't it be funny

#

if I spent several hours debugging something cuz I accidentally shadowed a variable

#

and then I fix that and I get a wrong result

#

๐Ÿ˜ญ

#

fucken "works with sample but not real input"

spiral zinc
#

noooo

bold coral
#

I know my solution is dreadful

#

but I've spent so much time on it

#

and now it doesn't work

#

๐Ÿ˜ญ

spiral zinc
#

btw here's my plans for part 2, if at all comprehensible to anyone here

bold coral
#

those notes make almost as much sense as my code

spiral zinc
#

lol

#

they make sense to me, and that's the important bit

bold coral
#

can I get someone else's input?

#

just for debugging

spiral zinc
#

uh one moment

bold coral
#

wanna see if there's something I missed

spiral zinc
bold coral
#

and your solution, if available

spiral zinc
#

none yet lol

bold coral
#

nope

#

doesn't crash

#

so IASHGOPIAHSFGOPJASO:IJFGOP:AISHJFO:IAHJSOP:IT HGo;h

#

o;ai

#

ed hgo;iszhdg ;iohas

#

do;ig h

#

oh fuck it wants the lowest one that corresponds to one of the starting values

#

๐Ÿ’€

ripe lance
#

do the seed maps have overlapping zones?

spiral zinc
bold coral
#

would it?

#

cuz I just spent quite a while on doing that

#

:')

spiral zinc
#

because it's always possible to get an output of 0, right?

bold coral
#

no?

ripe lance
#

still youd only have to look at the last one

spiral zinc
#

wdym no?

bold coral
#

I mean.. no?

ripe lance
#

if a map includes 0

bold coral
#

I assumed you were to give the lowest value of any of your location ranges

#

that isn't just always 0

#

it's 54927065 for me

#

and it's 46 for the sample, which threw me off

bold coral
#

no

#

you need to give the lowest value that is also in the starting ranges

#

basically, get the overlap of the starting value and the final value, and the lowest one of that is the answer

spiral zinc
#

not "that is also in", just "that one maps to"

bold coral
#

squint

#

ok I double misread

#

and I'm confused again

#

qwq

#

I'm applying all the thingies
then taking the smallest value in the location values

#

and that's too big

#

๐Ÿ’€

spiral zinc
#

i think that just means there's a bug in your code-

bold coral
#

yes

#

but there's literally no way I can find out

#

short of super-fine-combing my entire code

ripe lance
#

i love higher level functions you can start by writing down what the puzzle says and then its done

bold coral
#

what do I do now

#

suffer and debug

#

or suffer and rewrite everything

spiral zinc
#

both :D

bold coral
#

at this rate I won't finish before Christmas

#

I give up

bold coral
stray violet
#

My solution was not efficient

#

Iโ€™m not smart enough for that

bold coral
#

I'm not smart enough to make my solution solve it

spiral zinc
#

holy shit i did it

bold coral
#

ok great helpe me

#

qwq

stray violet
#

I need the โ€œsmartโ€ solution explained to me I donโ€™t understand it

bold coral
#

I need a solution

spiral zinc
#

lol the uiua pad url doesn't fit in a discord message

bold coral
#

apparently I'm really bad at giving up on purpose

spiral zinc
spiral zinc
bold coral
#

:3

spiral zinc
bold coral
#

get the overlap of the sections you have already and the mapping, then make new sections from that

spiral zinc
#

(mostly ignore the first page, that's just the algorithm to get the intersection and both tails)

bold coral
#

that's what I'm doin

#

thonk

#

are there sections that map two mappings

spiral zinc
#

what's your range intersection algorithm?

spiral zinc
#

can you give an example

bold coral
#

e.g. a seed 1-20 and then a seed-to-soil of 2-10 => 1-9 ; 11-20 => 1-10

#

cuz I think I'm only checking for one of the mappings

#

(mappings is what I call the things in seed-to-soil etc)

spiral zinc
#

yeah you need to check both

#

although the outputs of the mappings are disjoint

bold coral
spiral zinc
spiral zinc
bold coral
#

just both in my example, y'mean

#

ah

spiral zinc
#

yeah

bold coral
#

well that'd do it

spiral zinc
#

yep

bold coral
#

I'm gonna go buy energy drink

#

Then hyperfixate on solving part 2 again

spiral zinc
#

gl!

stray violet
#

I think Iโ€™m starting to get it

#

but Iโ€™m eepy

spiral zinc
#

now i have to go and actually write that traveling salesman implementation for my ds&a class

bold coral
#

I recommend you look at my current part 2 attempt to see how bad it is

stray violet
#

oooh I love tsp

bold coral
#

I've actually got a mathematically perfect tsp solution

#

Simply outlaw door-to-door selling

spiral zinc
#

true!

bold coral
#

No salesmen, no peoblem

spiral zinc
#

simply reduce all graphs to K_0

bold coral
#

does a basic assert to check if my assumption was true
instantly fails

#

ok now I know why it didn't work

#

I don't know how to fix it tho

bold coral
#

I still have no iddea

#

aa

#

AAAAAAAA

spiral zinc
#

what was the assumption?

bold coral
#

The assumption that only one of the mappings would ever apply

#

So now I need to reason out how to apply two or more at once

bold coral
#

I still have no idea

#

will keep you posted

#

:โพ

#

I'm going AAAAAAAa

bold coral
#

ok so
I apply all the mappings
and then, after I have all the new ranges, I need to somehow figure out the parts that weren't mapped

#

which
no idea

#

I can visualize it

#

I just don't know how I'd turn that into a program

spiral zinc
bold coral
#

not in a way I could think of, no

#

basically I start with my seeds (or otherwise) X
have a bunch of mappings of Y -> Z
and I need to remove Y from X

#

and at the end join X and Z, and that's the actual mapped ranges

#

I can do the Y -> Z, but not the remove Y from X

spiral zinc
#

ohh i see

#

what i did was that ||my intersection function takes the range Rx from X and the range Ry from Y, and returns 3 ranges: one for what is in Rx before Ry, one for the intersection, and one for what is in Rx after Ry, and then put the first and third back into X and the second into Z||

bold coral
#

yes I have that

#

not sure that helps me for the final step tho?

#

idk I'm confused

spiral zinc
#

ig really i kinda rebuild X each time?

bold coral
#

I have the function that gives me the three different sections

#

implemented very badly and painfully

#

but I have it

#

if I put Z back into X immediately, then they might get double-mapped and that's wrong

spiral zinc
#

very very tangential sidenote, but there's a fun property of representing ranges in uiua: you can represent it either as an array [StartingIndex Length] or an array [StartingIndex EndingIndex], and you can convert the first representation to the second with \+ and the other way around with \-

spiral zinc
#

presumably the outer loop iterates over entire maps (i.e. seed->soil or w/e)

bold coral
#

no, I just do that 7 times

spiral zinc
#

so you have two layers of loops then?

bold coral
#

uh

#

maybe?

#

I have 7 loops that iterate over the seeds/soils/whatevers and applies the first mapping that overlaps that seed/soil/whatever range

#

just like
the same loop copy-pasted 7 times

spiral zinc
#

ig my question is, does it iterate over these or these?

bold coral
#

the former

#

and then the latter insofar as seed_to_soil.iter().find(|mapping| mapping.overlaps_with(seeds))

#

when instead it should just apply all of them instead of just the first one

spiral zinc
#

yeah, i did it in the other direction

bold coral
#

how does that work

spiral zinc
#

not exactly sure how i'd approach it your way, though i don't think there should be any reason for it not to work

spiral zinc
bold coral
#

the reason is that my brain is shrivelled up and sad and I can't think

#

:')

spiral zinc
#

this guy

bold coral
#

that helps literally none at all

#

lmao

spiral zinc
#

so the 0,100 in the top left is just the input range we're starting with, and this part is the mappings

#

so then i keep two lists of ranges, applied and unapplied

bold coral
#

I don't think starting from scratch would help either cuz I can't properly envision a different way to do it

spiral zinc
#

and the table shows how they change through the process

#

so we start with these ranges in the unapplied array

#

then we look at each of these guys

#

for each of them, we iterate through unapplied and put the intersection into applied, and the disjoint bits into a new version of unapplied, that gets assigned back to unapplied at the end of the iteration

bold coral
#

squint

spiral zinc
#

then at the end we just join applied and unapplied

bold coral
#

I think I understand?

#

... no I don't

spiral zinc
#

does my explanation make the diagram make more sense?

bold coral
#

if I put the disjoint bits somewhere else, they aren't mapped by the following mappings

spiral zinc
#

that's why you assign it back to unapplied after each line of the mapping

bold coral
#

so

seeds = [array of ranges]
soil = []
for each mapping in seed_to_soil {
  new_seed_ranges = []
  for each seed in seeds {
    apply mapping to all ranges
    put moved ranges into soil
    put rest into new_seed_ranges
    remove seed from seeds // I can't do this because I'm iterating over seeds
  }
  join new_seed_ranges back into seeds
}```?
spiral zinc
#

almost--you don't need remove seed from seeds, and join new_seed_ranges back into seeds goes outside of the inner loop

#

it's really not join

#

it's replace

bold coral
#

why do I not need remove?

#

and wym by replace

spiral zinc
#

because we're replacing all of seeds anyway, at the end of the outer loop

#

like just seeds = new_seed_ranges

bold coral
#

๐Ÿค”

#

ok I'll try that

spiral zinc
#

gl!

bold coral
#

ok implemented for the first of 7 steps and the example still works

#

and now I broke it

#

๐Ÿ˜Ž

#

ok I forgot to add the completely unaffected ones to the next step

bold coral
#

I have once again implemented something that gives me a correct solution for the example but gives me 0 at full input

spiral zinc
#

noooo

bold coral
#

ok but it seems like it's a bug

#

cuz I think there's a 0 that comes from nowhere

#

build technical debt% speedrun

#

never had a single-day thing become so unmanageable so quick

spiral zinc
#

lol true

bold coral
#

oh wait

#

I was not printing a thing so I'm more confused

spiral zinc
#

when i was working on my solution i had so many dumpids (uiua's "debug print everything")

bold coral
#

in my defense:
it's really well formatted

#

(looks like this for sample input)

spiral zinc
#

watr

bold coral
#

I wanted all of them to be 4 characters so they're aligned

spiral zinc
#

yea

bold coral
#

ok it doesn't return 0

#

it returns something else that's too big

#

OFF BY ONE ERROR

#

I AM ONE STEP CLOSER TO RESTORING SNOW OPERATIONS

#

@spiral zinc tysm for help qwq

spiral zinc
#

:D

#

nice woem

bold coral
# bold coral ***OFF BY ONE ERROR***

(I noticed that I had numbers that were the ending and starting value of my ranges, and I had been using inclusive ranges for everything, so I just subtracted 1 from everything's endings)

spiral zinc
#

oh yeah

#

i used exclusive ranges since that was the input format

bold coral
#

.. was it??

#

am I dumb?

#

I think I might be dumb

#

ok yea I'm dumb

spiral zinc
#

i mean the input format was like 20 5 representing 20..25

bold coral
#

x..=x+length is length length + 1 and that's just .. THE off-by-one error

spiral zinc
#

oop

bold coral
#

:')

#

I got there tho

#

and for some reason that didn't cause an error before so who careesss

#

and

#

it still runs super fast

#

comparatively

#

695 micros

#

day 4 is almost a whole millisecond on average

#

running strings on my executables is very informative

#

.. huh
for RangeInclusive, start and end are private fields only exposed via getter methods

#

for Range, they're public

bold coral
fickle hornet
#

Need of sleep and tiredness suck

real robin
#

annoying how today's one the higher/lower hint is not helpful at all

#

reruns same code
gets same answer
confused

real robin
#

i am not enjoying this one because it's a fucking pain to debug

#

i have NO clue where this bug is and i have NO clue if i'm over or under counting or anything like that

fickle hornet
#

Chop up your splitting code into small bits which you test individually?

real robin
#

yeah I mean I've written this pretty modularly so it's not bad to test but

#

the annoying thing is that

#

it works on the example they gave

#

so I don't even have a small case I can debug

#

and idk where the edge cases are because the parsing seems to work fine

#

and it's mostly parsing

#

huzzah!

#

my parsing was wrong

#

||i'm parsing each map into a struct individually and then i have a traverse function which does all the looking up. in parsing each map into a struct i was just forgetting to pick up the last one because of the way my parsing works

i just got lucky that the last map in the example one didn't do anything to what ended up being the answer||

#

having written part 1 the way i have, it seems like part 2 should be easy (famous last words)

fickle hornet
#

What structs do you have?

real robin
#

here is my code from part 1
||```rust
fn main() {
let input = include_str!("input.txt");
let result = calculate(input);
println!("result: {}", result);
}

#[derive(Clone, Copy, Debug)]
struct MapItem {
destination_range_start: i64,
source_range_start: i64,
range_length: i64,
}

#[derive(Clone, Debug)]
struct Map {
map_items: Vec<MapItem>,
}

impl Map {
fn new(input: &Vec<&str>) -> Self {
let mut map_iter = input.iter();
let _ = map_iter.next();

    let mut map_items: Vec<MapItem> = Vec::new();
    for row in map_iter {
        let numbers: Vec<i64> = row
            .split_whitespace()
            .map(|x| x.parse::<i64>().unwrap())
            .collect();
        map_items.push(MapItem {
            destination_range_start: numbers[0],
            source_range_start: numbers[1],
            range_length: numbers[2],
        })
    }

    return Map { map_items };
}

fn traverse(&self, input: i64) -> i64 {
    for map_item in &self.map_items {
        if ((map_item.source_range_start)
            ..(map_item.source_range_start + map_item.range_length))
            .contains(&input)
        {
            return input - map_item.source_range_start + map_item.destination_range_start;
        }
    }
    return input;
}

}

#[derive(Clone, Debug)]
struct Maps {
maps: Vec<Map>,
}

impl Maps {
fn new<'a, I>(input_iter: I) -> Maps
where
I: Iterator<Item = &'a &'a str>,
{
let mut paragraphs: Vec<Vec<&str>> = Vec::new();
let mut temp_lines: Vec<&str> = Vec::new();
for item in input_iter {
if item != &"" {
temp_lines.push(item);
} else {
paragraphs.push(temp_lines.clone());
temp_lines = Vec::new();
}
}
paragraphs.push(temp_lines.clone());

    return Maps {
        maps: paragraphs.iter().map(|x| Map::new(x)).collect::<Vec<Map>>(),
    };
}

fn traverse(maps: Maps, seeds: Vec<i64>) -> Vec<i64> {
    let locations = seeds
        .iter()
        .map(|seed| {
            let mut current_seed_location: i64 = seed.clone();
            for map in &maps.maps {
                current_seed_location = Map::traverse(&map, current_seed_location)
            }
            return current_seed_location;
        })
        .collect::<Vec<i64>>();
    return locations;
}

}

fn calculate(input: &str) -> i64 {
let lines = input.lines().collect::<Vec<&str>>();
let mut lines_iter = lines.iter();
let mut seeds: Vec<i64> = Vec::new();
if let Some(seeds_line) = lines_iter.next() {
if let Some((_, seeds_str)) = seeds_line.split_once(":") {
seeds = seeds_str
.split_whitespace()
.map(|x| x.parse::<i64>().unwrap())
.collect();
}
}
// remove that one blank line lol
lines_iter.next();

let maps = Maps::new(lines_iter);
let locations: Vec<i64> = Maps::traverse(maps, seeds);
return *locations.iter().min().unwrap();

}

#

it's ugly asf lmao but i wanted to try parsing the data into a proper struct

#

i just think today maybe wasn't the day for that

#

i also think that this solution is too inefficient to use on part 2 lol

#

maybe if i leave it cooking overnight

#

yeah not gonna work lol

fickle hornet
#

Why do you have Map and Maps?

real robin
#

idk horrible naming

#

tech tebt because of something that i threw together quickly lmao

fickle hornet
#

Or rather why do you have a vector of maps and then a vector of vector of maps

real robin
#

MapItem is just a single row from a map, Map is then a whole map (seed-to-soil) and then Maps is just all of it

fickle hornet
#

Ah

real robin
#

wacky i know and not very much thought has gone into it

#

if i had to rewrite it (which it looks like i will have to do anyway) i would not do the same thing lmao

#

I think I'm gonna have to work with ranges of values and then work my way down

fickle hornet
#

I just had a vector of tuples for each map and put those in a vector, structs for that feels overengineered or bloaty

real robin
#

it almost definitely is

quiet frigate
#

Day 6 gonna drop and I haven't even done 4 or 5 ๐Ÿ˜ญ

stray violet
#

today's had better be more tolerable

fickle hornet
quiet frigate
#

I looked at 5, my eyes crossed then glazed over

#

I'll try 4 though. Seems simple enough

#

naturally, I'll solve it with regex

#

apparently someone did day 5 part 2 with a GPU

#

that's great

fickle hornet
#

||anyone remember what word to search for to get the "optimization" formulas related to this day? I've completely forgotten it in Finnish since my high school days and don't even know it in English :>||

stray violet
#

||I think I have the formula but I'm kinda dumb||

#

||+/- 1 here and there||

#

I threw so hard

#

my code could have brute forced it in 30 seconds and I spent 5 minutes doing math

fickle hornet
#

||If you were smart and know that the input goes false -> true -> false then numbers of that scale are so fast to bruteforce. If at first it's false then test if you can skip ahead, if you can then test if you can skip ahead even more until your test gives positive results and then when the results go false again then break your loop and report result||

#

||1.62s for the whole exec of a bruteforcing debug build (probably without any optimizations enabled) on i7-7600k||

spiral zinc
#

||well ig it's nice to have a break after yesterday, but this was way too easy||

#

||it wasn't even difficult algebra /complain||

quiet frigate
#

I look forward to doing it tomorrow then :)

bold coral
#

that is

#

very little input

#

and I'm scared of what that means

bold coral
#

ok

#

this year is just all over the place with difficulty

#

12 hours yesterday, 20 minutes today

#

๐Ÿ˜ตโ€๐Ÿ’ซ

fickle hornet
#

eh, it has now consistently been hard into easy in pairs

#

so expect tomorrow to punch your teeth out again

bold coral
#

oh no

#

I literally had to change nothing for day 2

#

actually yes I did

#

the data type

#

from u16 to u64

#

solved 9 hours earlier, but only 5000 ranks higher

spiral zinc
bold coral
#

in uiua, 5 characters is like a whole paragraph in Rust

#

/hj

spiral zinc
#

lol

#

it was 2 changed for parsing, 2 changed for not multiplying (though come to think of it they probably could've been left in), and one since it was using scalars instead of arrays

real robin
#

today was so easy lmao

#

very refreshing after yesterday

#

||and part 2 was just a modification to the parsing so not even difficult!||

stray violet
#

real

real robin
#

i still haven't finished part 2 from yesterday lmao

spiral zinc
#

not many here have

#

day 6 part 2 already has more solutions than day 5 part 2

ripe lance
#

still havent done day 5

#

i started it but my parsers werent working correctly

#

i do really wanna do it, and ill probably get ot it tomorrow

bold coral
#

I wonder if they'll expand the example of day 5 eventually

#

Cuz there's so many edge cases that are not easy to debug at all

real robin
#

in general it's so hard to debug

#

like i think i'm close i just haec one piece of wrong arithmetic or something

stray violet
#

what's your approach?

real robin
#

start with ranges of seeds

#

check for overlap against ranges that get mapped

#

map the overlap

#

leave the other bits

#

pass everything to iteration 2 and repeat

stray violet
#

I see

real robin
#

is that the right angle generally speaking?

spiral zinc
#

yeah that's pretty much what i did

stray violet
#

sounds good yeah, does it work on the small data?

real robin
#

not quite yet

#

not sure where the issue is

#

I did have it working on small data but it broke on large data so I rewrote a bit and now it doesnโ€™t work on either

#

๐Ÿ™ƒ

bold coral
spiral zinc
#

so far i've mostly managed to avoid having algs that work for the small input but break for the big input, i hope i can keep it that way

spiral zinc
#

quite possibly

real robin
#

My impression of uiua is that you basically encode the underlying structure and then ask for a number

#

Not sure if thatโ€™s a good impression or not but itโ€™s the one I get

spiral zinc
#

honestly that sounds more like fp than something like uiua

severe flame
#

took me over a day

#

but I did day 5 part 2

#

in not 40 minutes

#

on my trash cpu

#

some of my proudest code

#

It is not good

#

but

#

I am proud of it

slate zephyr
#

I don't have a computer anymore (visiting family)
I'm going to fall so far behind :(

#

I'm already two days gone

ripe lance
#

describing what things are

#

declarative programming can look really lovely

fickle hornet
#

Procedural programming is my beloved <3
OOP sucks and FP is too hard to grasp and keep track of

stray violet
#

I might be out at the time the problem launches today

#

life over aoc ๐Ÿ˜ญ

spiral zinc
#

yeah i'm always out for the first 90 minutes or so from launch

stray violet
#

I am out with people that do aoc and one of them has already expressed an interest in doing it live ๐Ÿ’€

quiet frigate
#

I have entered my depressive episode eraโ„ข๏ธ so I have not had any ability to do them :(

severe flame
#

I can't wait for the day 7 monster

#

lmao

fickle hornet
severe flame
#

lmao

#

I got 30 minute sfor the solve

#

it's either I am done in 30 minutes

#

or in 15 h when I am back from university

#

or I skip sport

#

hmm

fickle hornet
#

oh no

severe flame
#

I gota solution it works on the sample input not on my input fuck

fickle hornet
#

I'm still grasping how should I check how many different cards there is and figure out what kind it is then

#

15 minutes in and 82 people have already finished

severe flame
#

oof

#

I was sorting the array wrong

#

fuckkkk

severe flame
#

no time to finish solve

#

brr

severe flame
#

I solved it oncthe bus on my phone .-.

ripe lance
#

"oh day 5 part 2 doesnt seem that bad" oh god wait this is gonna take a millennia to figure out

bold coral
#

How are people solving it in a way that takes so long

#

Are y'all actually going through every number?

ripe lance
#

..yes

#

crankin away

#

i do not i think thisll work

ripe lance
#

this is not practical

#

im kinda stumped

#

i probably have to rewrite everything into a much more verbose structure and analyze redudant ranges

#

cus most of it is redudant ranges

#

ill work on it some more later

#

excited tho

#

this is my favorite one so far

bold coral
ripe lance
#

ye

jaunty hawk
#

I've been slacking off so much

spiral zinc
#

and i'm now officially further than i got last year

fickle hornet
#

now for pt2 /_\

#

150 LoC for pt1 which I needed Ord trait implementations and stuff for

#

*reads pt2* oh no...

spiral zinc
#

it's not nearly as bad as it sounds lol

fickle hornet
#

example output matches my output with example input, my input's output doesn't match expected output

quiet frigate
#

That's so ass

bold coral
#

not sure how to turn five cards into a hand

fickle hornet
#

At least for my implementation it's completely awful

bold coral
#

wh

#

why does my thing only work for sample input

#

what order of magnitude should the answer be?

#

I'm in the hundred-billions range ๐Ÿ’€

fickle hornet
#

I'm balling around 9 digits

bold coral
#

so the same

fickle hornet
#

fucking finally

bold coral
#

D:

ripe lance
#

i love when my parser just fails. for no reason. why are you doing this

#

oh my god wait its bit limit again

#

ughn

#

okay day 6 was absurdly easy

bold coral
#

yea

#

I have no idea why my day 7 is wrong

#

:c

bold coral
#

I forgot to check for extra cards so that a AAA32 and AAATJ were considered equal

#

c:

bold coral
#

it still doesn't work

#

:c

#

fixes a bug
it becomes even further from the result

stray violet
#

I know thereโ€™s a nice greedy solution for part 2 but you know what they say

#

Naive always wins

spiral zinc
bold coral
#

Ig I'm skipping today

#

:(

loud vale
#

My day 7 part 2 code passes the sample solution but not the real solution wtf ๐Ÿ™ƒ

stray violet
#

I need aoc like all year, itโ€™s actually good motivation to sharpen coding skills

#

Could always redo previous years

stray violet
#

ahahahahaah

stray violet
#

this was fun

severe flame
#

SHIT I WOKE UP LATE

stray violet
#

you're still miles ahead dw

fickle hornet
#

is pt1 supposed to take a while to crunch..?

#

Or did I fuck up and loop

#

I let it run for a minute and 22154890 crossroads wasn't enough to find the destination, oh no

stray violet
#

I got part 1 almost instantly

ripe lance
#

yay linked lists

fickle hornet
#

Oh ffs ||it always starts from AAA, not from first line's str||

ripe lance
#

im gonna make this overly complicated

fickle hornet
#

Either I fucked up or 10 mins isn't enough to compute on my CPU :>

#

How many digits did the pt2 answer have?

bold coral
fickle hornet
#

I'm currently "bruteforcing" it at 662324623, I have no idea what the meth shortcut is here

#

Even though I only have 6 things in my vector this doesn't seem to be ever ending nor do I have any leads atm

fickle hornet
#

1254853528 erm...

#

Did I overshoot already or how long will it still take?

spiral zinc
#

apparently it was on the order of 10^13

#

so you're 0.1% of the way there

fickle hornet
#

10 digit number after 2h...

#

10**10/10**13=0.001
2000h
83d
maybe I'll stop...

spiral zinc
#

hehe yeah

fickle hornet
#

Any magic words for search engine for the meth theorem/formula? :>

#

Otherwise it's just a knowledge diff, completely stumped and can't finish today

spiral zinc
#

yeah i had to get some hints, there's the ||chinese remainder theorem||, although ||there are certain properties that always hold with the inputs they gave to this problem that means that an easier solution is possible||

stray violet
#

I literally just guessed that it would be ||the LCM of all the periods, I'm bad at math||

#

||if that was wrong I'd have been screwed||

bold coral
#

I forgot about yesterday

#

Zamn

spiral zinc
#

oops lol

#

today's was ||nice and straightforward though||

loud vale
#

Took me a few minutes to wrap my head what needed doing, but it was pretty good.

spiral zinc
#

i had kinda hoped it'd be the kind of challenge where ||the straightforward solution was too slow so you had to construct a polynomial instead||

#

but honestly ||idk if that would even be an optimization||

#

probably would be if part 2 was like "generate the millionth number in the sequence" or smth like that

#

but even then it could be optimized without that strategy, so idk

stray violet
#

wahoooo I forgot one

severe flame
#

if any of y'all might be able to help out

#

that'd be great

#

I am honestly stuck

fickle hornet
split night
#

lmfao

split night
# fickle hornet still a great meme

miku "miku-chan03"

  • helped installing Arch Linux on all her friends' PCs
  • contributes very helpful PRs in uwulang, maintainers thank her without questioning further
  • types as fast as Yuki Nagato from The Melancholy of Haruhi Suzumiya
  • expert in low level graphics programming with OpenGL
  • wears cute cat ears and programming socks, drinks Monster on the daily to boost up productivity
ripe lance
#

can someone give me the solution to line 1?

spiral zinc
#

line 1?

ripe lance
#

the first line of the imput

#

so i have something better to compare against

#

although i think i know the problem

spiral zinc
#

...i mean everyone has a different input file so unless you share yours there's not much we can do

ripe lance
#

wait really

#

i didnt know that

#

that makes so much sense

#

i just dont understand

spiral zinc
#

what's your algorithm, roughly?

ripe lance
#

push a set thats the difference of each pair of the previous set until its all 0s

#

reverse it, push a 0 to the first set, and push the last value of the prev set added to the last value of the current set

slate zephyr
#

Day 7 Part 2 Solution
I think it came out really well (highlighted is the actual computation parts)

stray violet
#

Iโ€™m on the bus home, no clue if Iโ€™ll make it on time yet KEKW

stray violet
#

part 2 is impossible

fickle hornet
fickle hornet
stray violet
#

bruh I've been saying the words "up" and "down" out loud nonstop for 2 minutes trying to trace these paths and I sound like the fitnessgram audio

stray violet
#

I think I'm close

stray violet
#

wow that was fun

#

apparently there is a better way to do part 2 by using ||bfs and flood fill|| but I came up with something a little more unhinged that I'm pretty proud of

spiral zinc
#

i'm gonna write an algorithm that's so inefficient--

spiral zinc
#

aaaaand done!

winter ether
#

has anyone done day8 part 2? idk if i'm doing something wrong or my input is unlucky but my algorithm is struggling

#

could you run this through your solution and see if yours finds an answer?

winter ether
winter ether
#

ough, idk what i'm doing wrong...

#

it should be moving all curr_locs to the next and check if they all end in 'Z' to stop

spiral zinc
#

oh yeah ||that won't work, the total number of iterations is far too big (on the order of 10^13)||

winter ether
#

oh... guess it's too big brained for me then i can't think of any other way

slate zephyr
#

Observe: my absolute mess of a day 9 part 2!
Part 1 came out really neatly, part 2, uh, did not
(I just found out ||VecDeque doesn't have windows(), that was surprising||)

#

So far the only day that's bested me is day 5
I just can't with it
I parsed it and now I have no idea how to continue

spiral zinc
winter ether
#

oh no day 5, i could only do part 1 because part2 is too big brained like day8 part 2

bold coral
#

just got on my PC for the first time in a few days

#

๐Ÿ’€

#

guess I dropped out of aoc ๐Ÿ˜”

winter ether
#

lol i've been dragging 2 days behind ever since it started. it'fine

bold coral
#

vacation just started and now my body went into hibernation mode

#

I've slept like 16 hours the last two days

#

cat mode

halcyon lotus
#

I solved days 1-7 but a bunch of other coding projects up that are actually important have piled up so I was forced to drop out qwq

winter ether
#

i have no intuition on why ||lcm|| works i can't convince myself it does

slate zephyr
#

Like

#

||Imagine two clocks: one strikes 12 every 10 minutes and the other every 15||

#

||How much time will pass until they meet again?||

#

Edited, typo

#

Same thing but with the ||ghost paths||

#

||Because the cycle is closed and periodic||

winter ether
#

aye till there i'm with you but i don't see how the input would create a cyclical structure

spiral zinc
#

part of it is assumptions you can show are true about the inputs they actually give

#

part of it is that since there's only finitely many possibly states you're bound to return to a previous state and end up in a cycle eventually

slate zephyr
#

^^
The way I see it: ||the input is finite, and you can't "stand still" (I assumed, might not be true now that I think of it), so you gotta end up at a cycle Eventually||

spiral zinc
#

they only give you inputs where ||the cycle length is equal to the distance between the starting point and the z||

winter ether
#

hmmmm make sense, you'd still need to assume that the ||the first z you meet is the end of the cycle||

spiral zinc
#

i mean a cycle has no well-defined ||end point|| lol

winter ether
#

aggh too many assumptions for my taste

spiral zinc
#

yeah, you can show that they're true for your input though

#

but i didn't like it either

slate zephyr
#

I didn't check them, I just thought ":o wait is it ||mcm||? *turns it in* it was! neat"

slate zephyr
#

Aaaa (Day 10 part 1)

#

I can't stop the ||recursive function from spreading not-outwardly||

winter ether
#

i suggest ||you have a param that keeps track of the previous step so you don't go back on your feets||

slate zephyr
#

I do
||Each cell has a seen bool||

#

I'm pretty lost

winter ether
#

oh my, i think this is overcomplicating it

slate zephyr
#

i started with simple and complexity encroached

#

i have no idea how to approach this rn

#

This is what i've got rn

#

Everything that || find_longest_path ||depends on is probably correct, but it itself eludes me

winter ether
#

long screenshot

slate zephyr
#

It's not a screenshot >:)

#

It's Silicon, stolen found from tris' rust's install list

spiral zinc
#

long image of code then

winter ether
#

i want to live in a world where your monitor is 2m high

#

but yah i still feel like this went too far into complexities

#

also the loop is only one, you shouldn't need a find_longest_path

slate zephyr
#

||The function starts at S and only travels across valid pipe boundaries||

#

I wonder what obvious result I'm missing

winter ether
# slate zephyr Wdym

S has only two pipes connected to it and they are connected to each other in a loop, the junctions never diverge bit the name kinda implies you think it might

#

that just confused me a little

spiral zinc
#

i've been trying to do all these right after i wake up but i won't be able to tomorrow

#

early exam :(

stray violet
#

this one was frustrating but good

jaunty hawk
#

i gotta start catching up to this stuff

#

i haven't done anything since like

#

day 4 or 5

hazy abyss
#

same

#

I am currently doing day 5 and oml

#

I do not understand this shit at all

#

nvm I just MISTYPED

#

i am going to implode

hazy abyss
#

I think your not supposed to brute force day 2 part 2

hazy abyss
#

why does it have to be so hard to spoiler code >:(

hazy abyss
fickle hornet
# hazy abyss why does it have to be so hard to spoiler code >:(

Skill issue

||```rs
fn par_generic_solver(mappers: &[Vec<MapRange>], seeds: impl ParallelIterator<Item = u32>) -> u32 {
seeds
.map(|seed| {
mappers.iter().fold(seed, |prev, map| {
map.iter().find_map(|range| range.map(prev)).unwrap_or(prev)
})
})
.map(|n| Some(Reverse(n)))
.reduce( None, |a, b| a.max(b))
.unwrap()
.0
}

#

||```
...
```||

hazy abyss
#

yes it didn't work

#

either way bleh

fickle hornet
hazy abyss
#

ยฏ_(ใƒ„)_/ยฏ

fickle hornet
#

If the block has || inside it then I think you're fucked
||```bash
false || true

split night
#

||```rs
println!("test");

split night
fickle hornet
#

Skill issue :)

split night
#

||```rs
println!("logic test: a || b");

#

welp

#

if you have a no-args closure or a logic or, you're fucked

fickle hornet
#

let a = | | 5 * 5; isn't valid no-args closure?

hazy abyss
#

time to see if day 6 part 2 can also be brute forced

#

yep

#

that was really fast

#

...even without rayon

#

day 6 part 2 nom my beloved
||```rs
fn number(i: &str) -> IResult<&str, u64> {
map_res(
fold_many1(
terminated(digit1, multispace0),
String::new,
|parts, part| parts + part,
),
|n| n.parse(),
)(i)
}

#

ig I'll day 7 then

#

no nom for this challange ๐Ÿ˜”

slate zephyr
hazy abyss
#

god have mercy (day 7 part 1)

#

I hate how this will probably work

#

wait wait

#

one fix

#

have to actually not repeat the cards.values() calls

hazy abyss
#

oh no...

#

the sample input is correct but the actual data isn't

#

fuuuuuucckkk

bold coral
#

Oh hey that's basically my solution and also my problem!

#

Like
Exactly that
With the length match and everything

hazy abyss
#

oh god

bold coral
#

Just executed a bit different
I take an array of card faces, sort it, then group by a==b to see what hand you have

#

:)

hazy abyss
#

still on it ๐Ÿ˜ญ

bold coral
#

Me too

hazy abyss
#

ah fuck

bold coral
#

Tho I've also not really done anything except play RimWorld and Minecraft on my PC for a few days

slate zephyr
hazy abyss
#

it does not seem to be the issue

#

if it's the issue I'm going to cry

bold coral
#

I'm going to make you cry either way

slate zephyr
#

I made unit tests for that part and that part only of AoC

#

With the samples and with my own examples

#

And thank God I did because I had the logic wrong lmao

hazy abyss
slate zephyr
#

Yipee

bold coral
#

I just implemented ToString for my hand, printed out all the parses hands, then compared with the input

bold coral
slate zephyr
slate zephyr
#

Wasn't there a name for when there's only one type?

#

I might be misunderstanding what the match does, though

bold coral