adventofcode.com/ >Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme. You need to register with an account but you can appear as anonymous.
Private leaderboard join code (currently full):
368748-e33dcae3
People who are inactive for 5 days will be kicked, but other leaderboards can be made if desired.
Alternative leaderboard for those waiting for inactives to be kicked from the first:
>All of the puzzles have solutions which will run in fifteen seconds or less
Ayden Green
I was going to post "Second for Haskell." but the thread was pruned when I hit submit. I think it's better this way.
James Morales
>doesn't remove the junk after the previous thread link >doesn't change the tagline >doesn't change the leaderboard to not being full >forgets to increment the general # the first time Lazier than haskell edition
Angel Evans
Yeah, I see it. They want to hide the truth. Caml rulez, C is second, and Haskell is just a meme.
Hunter Reyes
The wording of today was very bad. At no points did the text mention that marbles are worth something except the puzzle input. Also the second part, even though it was just two sentences, could be interpreted so that the other marbles are n points for the nth marble but the last marble is multiplied by 100 (for 25 marbles, the others are 1..24 but the 25th is 2500)
Nathan Robinson
Yes, it was hard to decipher, but there are always examples to help.
Uh lads my code is still running, how long is this going to take? Am i reading the challenge right for part two?
Jose Taylor
Implement a linked list
Grayson Lopez
or a circular list by using a double linked list
Liam Miller
That's still a linked list.
Eli Miller
Yes and no.
Benjamin Morris
more or less... read I have not seen updated calendar for last 3 days. I did see someone post pictures for yesterday and day before that today I think.
>my comment in day 6 and my picture in day9 I am doing pretty well in this aoc!
Noah Ortiz
You're lucky. I want to be in that calendar.
Jace Adams
love u bby
Brody Hughes
It's my mission to make it into as many as possible, so far I've made it into 5 of them.
Noah Lopez
god damn it. Good job user. Really impressive
Nathan Sullivan
Once the circle has more than 23 marbles (after two cycles), a single cycle has the form >extract 23 marbles c_0,..,c_22 from the circle, leaving a link to the previous marble p and next marble n >have new marbles m_0,..,m_22 >generate lists ps = c_0,m_0,..,m_18 and ns = m,_19,c_20,m_20,c_21,m_21,c_22 >append ps to p and prepend ns to n >add the score c_19+m_22 to a player marble%23
This can be implemented with an unrolled linked list and should perform a lot faster than any step-based solution, while having little overhead compared to . To minimize list operations, don't store the 6 marbles in front but use them directly in the next iteration. To minimize malloc calls, reserve a large pool of {nextptr, grabbedUpTo, marble[38]} structs to quickly save those 38 marbles that are pushed to the back. Or, instead of having a pool, process 2^k cycles at once, though you'll waste a third of your memory. And no need to be precise in the number of turns at the end, because only every 23rd turn counts. Moreover, at every point when you have m marbles, you can process up to m/23 parts in parallel because any marble c will either map to ps or ns (which are definitely mapped to the ps of the next cycle) or disappear, so you can multithread for what that's worth.
Then again, I can fill 64GB of zero-overhead marble pointers in a minute, so more speed is not that important.
Juan Robinson
* 1/23rd overhead because I never free the removed marbles
Hudson Howard
Part 2 run time 0.141 ms, ahahahah C++ strikes again, you can't do shit this fast in python that's for sure
Why does Rust think fundamental data structures are dangerous?
Colton Young
What is your input?
Colton Turner
number of players 468 last marble 7101000
Gabriel Taylor
I do it in 50ms with my C code.
Benjamin Mitchell
Oh, I'm sure there's an LLVM binding for Python out there. It's cute that you think there's anything unique about your programming language. Typical C++ fag completely ignorant about the modern world of programming. At leas C-fags KNOW what they'd be losing if they used a more abstract language. You C++ fags just think "muh speed" even though fucking plain old Javascript can run on your magnitude these days.
Hudson Torres
found the weblet
John Price
ok basically I suck massive dongs. compiling to release makes Crystal with bigboy input a whole lot faster
only took 120m with my python code. basically the same.
Jack Ward
120 minutes?
Chase Gonzalez
Wish I wasn't a britbong so I could get in on that 5am action
Dylan Cooper
Inaccurate. Font-end's very specialized these days. It's more UX than what you would traditionally call traditional "programming" (i.e. algorithms and processing) these days. More framework-based and tool-based. For the most part, anyway. There are some websited that are basically just full-on web-based applications (some more successfully than others).
Nicholas Wilson
shut up and go write a medium article or something you weblet enjoy your virtual machine
Justin Nelson
the c++ code I wrote compiles on gcc if I remove my iostream references and typedef my struct (or I could just refer to it as the long name). I'm sure if you ran my code on your computer it would also be 50ms.
Juan Barnes
Apart from the shittily worded part 2 (thought the last marble had a custom score, rather than that it was about 100x more marbles), today's is super easy with a doubly linked list.
Runtimes are also fairly decent without actually putting any effort in (and I'm doing it in slow ass java as well)
MarbleMania: [9/25] MarbleMania MarbleMania: Part 1 -> [367634] (16 ms) MarbleMania: Part 2 -> [3020072891] (173 ms)
Samuel Williams
173 minutes, java btfo
Jaxon Ward
no 'ms' is centuries, for about a fifth of a millenium ; ezpz
you got a different answer for the second part compared to
Jacob Mitchell
One small improvement later and getting sub-100ms (although is still faster but hey) on part 2. poojet java can shit faster than the C++ fag can swallow his own cum it seems
>attempt to use my function on examples >(9, 25) -> 32 good so far >(10, 1618) -> 8317 oh shit looks like i got it >(13, 7999) -> 146071 wait what, oh no >(17, 1104) -> 2764 wait but everything else is correct? >(21, 6111) -> 54718 i dont understand what could have gone wrong >(30, 5807) -> 37305 fuck it i'll just try it on the input and submit hoping for the best >too high guess today is my brainlet filter lads
Andrew Jackson
You're right haha! Forgot to change UInt32 to UInt64 in scores array
that's hot fucking garbage of a metric tho, top % of those that made it have code and solutions that work usually better than the rest of those that passed
Joshua Garcia
ok so i'm not usually one to complain about imaged being cluttered with too much shit, but goddam this is on a whole other level
Aiden Long
Brainlet here, stuck on day 2 challenge 1. I barely know regular expressions and thought that it's a good way to make myself learn them, but now I'm not sure if regex can do what I want. I want to test a string to see if any letter from range [a-z] appears exactly 2 times {2} globally. Halp?
why bother, use an unrolled linked list with say 32 elements in a chunk, so you use only 1/32th of the memory on pointers versus a regular doubly linked list.
should be much faster due to better cache usage as well
Christopher Wilson
that would require context-free parser meaning PCRE could do it
Wyatt Cooper
Out of all the problems day 9 looks like stupid busywork.
Jaxson Carter
> regular expressions parsing a context-free grammar
just because you can (by changing definitions) doesn't mean you should
Joseph Brown
but you can, that's what makes PCRE special (not in a good way)
Austin Wright
Fuck it, I'll just sort the string alphabetically and loop over it to see if there are consecutive characters matching my needs. Brainlet solution is better than nothing.
I bet a lot of regex implementations can do the same kind of thing, you could use backreferences I think?
but I wish they all called themselves regexes at least, instead of regular expressions (PCRE is perl-compatible regular expressions, no?)
that's a better solution in my opinion. getting in the habit of using stuff like backreferences is just a bad idea
David Brown
backreferences make it context-free and not regular anymore
Nathan Morgan
My 45ms code is in the last thread if you want to do a comparison on your machine.
Chase Thompson
I know.. that's what my whole point is. There's no efficient ( O(n) ) way to implement backreferences and it ignores the whole theory behind regular expressions in the first place, so I don't like them.
Connor Rogers
Can you post your code? Mine runs in 900 ms with 412 players and 71646 as the last marble: void rotate_iterator(std::list& circle, std::list::iterator& it, int n) { if (n > 0) { while (n-- > 0) { if (it == circle.end()) it = circle.begin(); std::advance(it, 1); }
if (it == circle.end()) it = circle.begin();
} else if (n < 0) { n = std::abs(n); while (n-- > 0) { if (it == circle.begin()) it = circle.end(); std::advance(it, -1); } } }
Hold the fuck up. If you're using scanf (or any other variant) then why not just use pure C? What's the point of using C++ if not for the safety it provides?
Charles Adams
>not -Ofast -march=native
Ayden Walker
Ideally I want the input to come from a file, so would I have to open the file, get the line into a *char and then pass it to scanf? (If I don't want to use a file pointer)
read a string from an ifstream and parse it with sscanf
Hunter Ortiz
Scanf is slow. If you use scanf, you'll spend most of your run time in scanf for the big-boy input. This was discussed yesterday - the fastest solution wrote custom input parsing. It's easiest to read from stdin. This way, you can read from both a file via shell redirection and from, well, standard input.
Nathaniel Ramirez
that may be true, but it hardly matters for this problem where you just need to read two numbers once at the beginning
Benjamin Garcia
thanks, didn't make it faster but I'll remember it
Noah Evans
you could also use -Wpedantic to see possible errors