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
Munkeymon
Aug 14, 2003

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



daggerdragon posted:

(you did save it, right?)

Haha, I actually got up to 7 in the Chrome console and just closed it when I was done. Dunno if I feel like attempting it in there, though.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

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



KARMA! posted:

I spent so much time on 9 to get a recursive thing to work without crapping on me. Turned out sometimes js really fucks with its variables. Nothing a judicious use of var can't fix, but I still don't know where exactly it went wrong. Bah humbug.

For 7 I couldn't get my head around it until I figured out that the value of a wire was an equation with variables and if you knew the value of those variables you could substitute the equation for the resulting value. Keep looping over the wires until solved. If I had a cs background I'd probably create a graph from all the rules and walk it top to bottom, but eh close enough!

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.

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.

Munkeymon
Aug 14, 2003

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



Aww hell yeah - I might even have time to finish this year, heh

  • Locked thread