Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
IronDoge
Nov 6, 2008

Munkeymon posted:

I think that's what I'm going to have to do. My first attempt has been to transpile it to JS (bn RSHIFT 2 -> bo => function bo_wire(){return bn_wire() >> 2;}) and let the interpreter figure out the graph for me but that's so loving slow I left it running all day and it hadn't finished, which I expected problem 5 to do, but nooo - that took whole seconds. Second attempt was changing the transpiler to emit F# and then try to sort the calls to make it a valid F# program (single-pass compilers in tyool 2015!), but I can't get that second part of that right and doing it by hand? Bleh :(

Would have been done with this in an hour if my first attempt worked as well as I'd hoped.

https://github.com/JohnWang42/Advent-Code-Solutions/blob/master/day7.py

Mine's in python, but what I did was take each unique value and add make it into an object. Each object stores the values and the operator. If the value is an unknown variable, it'll run the recursive resolve function on it when I want to get the value of a particular variable. Now the trick to making not run like poo poo was to also store the value of the variable once it was fully resolved. That way I'm not solving for the same drat thing a million times over.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



IronDoge posted:

https://github.com/JohnWang42/Advent-Code-Solutions/blob/master/day7.py

Mine's in python, but what I did was take each unique value and add make it into an object. Each object stores the values and the operator. If the value is an unknown variable, it'll run the recursive resolve function on it when I want to get the value of a particular variable. Now the trick to making not run like poo poo was to also store the value of the variable once it was fully resolved. That way I'm not solving for the same drat thing a million times over.

Ah, so you just memoized results :doh: I just didn't think a ~300-line program with no loops could possibly take so long to resolve.

7 is appropriately Xmas-y in LinqPad because it shows you the call stack interactively in the gutter next to line numbers and it's like watching a strand of lights with a really good random setting.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.

Xarn posted:

Why is the site down just as I decided to procrastinate and code? :v:

Ah, sorry about that, I should have put a notice up this morning when the datacenter lost power >_< We were only out for like, 45 minutes. I'm just glad it happened at 10am and not near midnight :/

"Your server is offline" = worst alarm clock ever.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 15: Science for Hungry People ---

quote:

Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to do is find the right balance of ingredients.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
I like how you're giving us all these NP-complete problems but making the datasets juuust small enough that you can brute force them. :shobon:

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

LOOK I AM A TURTLE posted:

I like how you're giving us all these NP-complete problems but making the datasets juuust small enough that you can brute force them. :shobon:

The best part about that is that you don't need to have arcane data structure knowledge (aka a cs degree) to participate.

Volguus
Mar 3, 2009
I loving hate Day 12 (was away for a week, catching up now). Phase 1 was able to do without a json parser and no regex's (yet, knock on wood). And it was really simple and clever. And in phase 2 now it makes me either make a json parser, use one or implement some mind-twisting, soul-hating state machine that I'll remember forever in the "what not to do" section of programming experiences.

I guess I'll just have to get in line and use this son of jay ....

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 16: Aunt Sue ---

quote:

Your Aunt Sue has given you a wonderful gift, and you'd like to send her a thank you card. However, there's a small problem: she signed it "From, Aunt Sue".

You have 500 Aunts named "Sue".

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
I think this one was faster to solve by hand than it would have been to write any code.

Xarn
Jun 26, 2015

Volguus posted:

I loving hate Day 12 (was away for a week, catching up now). Phase 1 was able to do without a json parser and no regex's (yet, knock on wood). And it was really simple and clever. And in phase 2 now it makes me either make a json parser, use one or implement some mind-twisting, soul-hating state machine that I'll remember forever in the "what not to do" section of programming experiences.

I guess I'll just have to get in line and use this son of jay ....

I said it once already, but I just used an ad-hoc brace matcher...

C++ code:
size_t find_start(const std::string& str, size_t pos) {
    int square_level = 1;
    int brace_level = 1;
    while (--pos) {
        switch (str[pos]) {
        case ']':
            square_level++;
            break;
        case '[':
            square_level--;
            if (square_level == 0) {
                return pos;
            }
            break;
        case '}':
            brace_level++;
            break;
        case '{':
            brace_level--;
            if (brace_level == 0) {
                return pos;
            }
            break;
        default:
            break;
        }
    }
    assert(false && "unmatched parens");
}
Yes, I did run it in Release mode so the assert did nothing anyway, why do you ask? :v:

Volguus
Mar 3, 2009

Xarn posted:

I said it once already, but I just used an ad-hoc brace matcher...

...

Yes, I did run it in Release mode so the assert did nothing anyway, why do you ask? :v:

Yes, and then inbetween you had to find the offending string, then find_start again. I chose to keep a bit of my sanity and just use a drat parser.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 17: No Such Thing as Too Much ---

quote:

The elves bought too much eggnog again - 150 liters this time. To fit it all into your refrigerator, you'll need to move it into smaller containers. You take an inventory of the capacities of the available containers.

Xarn
Jun 26, 2015

Volguus posted:

Yes, and then inbetween you had to find the offending string, then find_start again. I chose to keep a bit of my sanity and just use a drat parser.

Eh, the rest of the solution was just using string::find in a loop and a bit more logic to find the ending "}" if applicable.

As for day 17, I'd love if the inputs started veering away from brute force. There is a proper and easy algorithm for this, but if I was doing these in Python I'd just brute force it because its easy and the input is insanely small.

voodoo dog
Jun 6, 2001

Gun Saliva
Thanks for posting this! I guess this is the time to familiarize myself with the basics of Javascript, I've been putting that off for much too long. Also most of the programming I'm doing nowadays is data transformation stuff, so it's nice to have some different challenges for once. Only have two stars so far, we'll see how far I'll come.

Lamacq
Jun 15, 2001

Breezeblock RIP
I've been having a heck of a lot of fun with this, thanks so much for posting. I've been doing them in Node to improve my JS skills (transitioning from mostly Python) and these have been fun and interesting puzzles so far. My solutions here: https://github.com/technivore/adventofcode.

I just finished Day 7 and man, that one was waaay harder for me than the first 6 days.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 18: Like a GIF For Your Yard ---

quote:

After the million lights incident, the fire code has gotten stricter: now, at most ten thousand lights are allowed. You arrange them in a 100x100 grid.

Never one to let you down, Santa again mails you instructions on the ideal lighting configuration. With so few lights, he says, you'll have to resort to animation.

ErIog
Jul 11, 2001

:nsacloud:
I've really been enjoying these puzzles. A lot of them are stuff I've done before through HackerRank or Project Euler, but the Christmas theming does make it more fun. Unfortunately I'm trying to do them in Ruby which I started picking up about 2 weeks ago so it's been harder for me than it ought to be.

Day 12 Part 2 has currently broken me over it's knee and told me I'm a naughty boy who's not getting any gifts this year, though. I know how I'd do it in Python or C#, but the way Ruby aggressively passes by value means I'm having a hard time finding a way to traverse the tree while pruning objects off of it. There's probably some simple language feature I'm missing. Any Ruby people have any, uh, pointers that might help?

ErIog fucked around with this message at 13:18 on Dec 18, 2015

Xarn
Jun 26, 2015

I haven't done it yet, but please tell me that part 2 is Game of Life on a toroidal board. :v:

ErIog
Jul 11, 2001

:nsacloud:

ErIog posted:

I've really been enjoying these puzzles. A lot of them are stuff I've done before through HackerRank or Project Euler, but the Christmas theming does make it more fun. Unfortunately I'm trying to do them in Ruby which I started picking up about 2 weeks ago so it's been harder for me than it ought to be.

Day 12 Part 2 has currently broken me over it's knee and told me I'm a naughty boy who's not getting any gifts this year, though. I know how I'd do it in Python or C#, but the way Ruby aggressively passes by value means I'm having a hard time finding a way to traverse the tree while pruning objects off of it. There's probably some simple language feature I'm missing. Any Ruby people have any, uh, pointers that might help?

Lol, so turns out I'm real dumb and was doing recursion in a really stupid way that was breaking everything because I was trying to mix returning bools and returning actual objects in my recursive function. Once I flipped it to either returning or not returning objects based on their child objects I was golden.

Volguus
Mar 3, 2009
What I hope is that in January we would get the really nice and elegant solutions to all these problems which would put my brute-forced crap to shame.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Volguus posted:

What I hope is that in January we would get the really nice and elegant solutions to all these problems which would put my brute-forced crap to shame.

If you found a nice, elegant, polynomial-time solution to most of these problems, you'd be off redefining human knowledge of mathematics rather than posting it as the solution to an internet programming puzzle.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.

Volguus posted:

What I hope is that in January we would get the really nice and elegant solutions to all these problems which would put my brute-forced crap to shame.

There aren't that many clean and elegant solutions, if the solution megathreads in the subreddit are any indication. Most people are just coding as fast and as sloppily as they can in order to hit the leaderboard, and half as many are taking the easy way out with libraries like itertools. Ah well.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 19: Medicine for Rudolph ---

quote:

Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very brightly, and he needs medicine.

Red-Nosed Reindeer biology isn't similar to regular reindeer biology; Rudolph is going to need custom-made medicine. Unfortunately, Red-Nosed Reindeer chemistry isn't similar to regular reindeer chemistry, either.

ErIog
Jul 11, 2001

:nsacloud:

I thought this one was kind of boring at first since it has some similarities to previous permutation puzzles, but Part 2 makes it a lot more interesting.

iSurrender
Aug 25, 2005
Now with 22% more apathy!
Just wanted to pop in and say thanks to the creator of this.

(Though I hate that I probably wont ever get the entire tree lit up.)

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 20: Infinite Elves and Infinite Houses ---

quote:

To keep the Elves busy, Santa has them deliver some presents by hand, door-to-door.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 21: RPG Simulator 20XX ---

quote:

Little Henry Case got a new video game for Christmas. It's an RPG, and he's stuck on a boss. He needs to know what equipment to buy at the shop. He hands you the controller.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 22: Wizard Simulator 20XX ---

quote:

Little Henry Case decides that defeating bosses with swords and stuff is boring. Now he's playing the game with a wizard. Of course, he gets stuck on another boss and needs your help again.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 23: Opening the Turing Lock ---

quote:

Little Jane Marie just got her very first computer for Christmas from some unknown benefactor. It comes with instructions and an example program, but the computer itself seems to be malfunctioning. She's curious what the program does, and would like you to help her run it.

iSurrender
Aug 25, 2005
Now with 22% more apathy!
<30 mins to write the interpreter, >60 mins to find the one bug which was caused by sloppy reading of the instructions.

Spraynard Kruger
May 8, 2007

Man, it really feels like the difficulty in these has ramped up lately, and yet, the top 100 on the leaderboard seem to always be half hour or less solves. I'm still stuck on finding algorithms for days 19 and 20 that can run in a reasonable amount of time. :(

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.

Spraynard Kruger posted:

Man, it really feels like the difficulty in these has ramped up lately, and yet, the top 100 on the leaderboard seem to always be half hour or less solves. I'm still stuck on finding algorithms for days 19 and 20 that can run in a reasonable amount of time. :(

Oh no, sir. Day 19 took drat near 4 hours just to cap the leaderboard at 100 gold. I had to go to work at 9am. :/ Good luck! :D

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
--- Day 24: It Hangs in the Balance ---

quote:

It's Christmas Eve, and Santa is loading up the sleigh for this year's deliveries. However, there's one small problem: he can't get the sleigh to balance. If it isn't balanced, he can't defy physics, and nobody gets presents this year.

No pressure.

iSurrender
Aug 25, 2005
Now with 22% more apathy!

On twitter Dec 16th Eric Wastl posted:

Today is the last easy #AdventOfCode puzzle. It's all uphill from here. (Or downhill, if it were a roller coaster.)

With the exception of today and day 19 part 2 I don't think the recent ones have been harder though.
I think the worst ones before that was Day 12 part 2 and Day 7.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.
And now for the grand finale...

--- Day 25: Let It Snow ---

quote:

Merry Christmas! Santa is booting up his weather machine; looks like you might get a white Christmas after all.

The weather machine beeps! On the console of the machine is a copy protection message asking you to enter a code from the instruction manual. Apparently, it refuses to run unless you give it that code. No problem; you'll just look up the code in the--

"Ho ho ho", Santa ponders aloud. "I can't seem to find the manual."

Merry Christmas, everyone!

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Urgh, I finished 16 and 21-25 by hand (being away from my normal dev machine), but now I guess I need to find somewhere to actually code up solutions to 17-20.

How long is this going to be up?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Jabor posted:


How long is this going to be up?

Since I won't have time to even start #1 until next week, I would love to know this as well.

daggerdragon
Jan 22, 2006

My titan engine can kick your titan engine's ass.

Jabor posted:

Urgh, I finished 16 and 21-25 by hand (being away from my normal dev machine), but now I guess I need to find somewhere to actually code up solutions to 17-20.

How long is this going to be up?

My friend has no plans to take it down. As long as the server can handle the traffic, it'll stay up. :)

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Finally had time to return to the problems after a busy December and restart all the way back at problem 7. Having it laid bare that I'm a systems programmer with little knowledge of algorithms is teeth-gritting sometimes, but that makes it all the more gratifying when I get the solution.

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015

chutwig posted:

Finally had time to return to the problems after a busy December and restart all the way back at problem 7. Having it laid bare that I'm a systems programmer with little knowledge of algorithms is teeth-gritting sometimes, but that makes it all the more gratifying when I get the solution.

You are in luck then, most of the problems are either intended to be solved by brute force, or solvable by using brute force because of small problem size. :v:

  • Locked thread