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
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

Adbot
ADBOT LOVES YOU

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.

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.

  • Locked thread