Forum menu
...
Day 14 was another quick one. Quite liked it but you could pretty much guess where part 2 was going to head..
I've just got round to Day 6 - lanternfish. I assume it's going to need some kind of clever coding to cater for part 2 to not make my laptop go pop?
using namespace System.Collections.Generic
$newlist = [List[int]]@()
$myList = [List[int]]@()
[int[]]$new
$lanternfish = Get-Content .\Day6.txt
$lanternfish.Split(",") | ForEach {
$mylist.add($_ )
}
for ( $i = 0 ; $i -lt 80 ; $i ++ ) {
$mylist | foreach {
If ($_ -gt 0 ) {
$new = $_
$new --
$newlist.add($new)
}
ElseIF ($_ -eq 0) {
$newlist.add(8)
$newlist.add(6)
}
}
$mylist = $newlist
$newlist = [List[int]]@()
}
$mylist.Count
I assume it’s going to need some kind of clever coding to cater for part 2 to not make my laptop go pop?
Yep.
Not got d14p2 yet. Yes, knew what was coming based on the use of the phrase 'This polymer grows quickly' in the description, but can't see a way to do it yet
If you want a hint...
The way I did it - there may well be better - I just kept track of the number of each pair. You don't need to know the order. You do, however need the first and last letter.
Then each generation - each Pair - for example NN becomes the same number of the two new pairs.
After all your generations - add how many of each letter you have, add the end ones, then divide by 2 to get the actual numbers (pairs double count all the letters except the end ones - but you've added those).
Now you have a (in my case) Map N -> 1234, C -> 4321, etc.
Edit - reading that, not sure it makes much sense.
If you want a hint…
I'm not sure that's a hint, so much as a spoiler.
I'm just catching up - spent FAR TO LONG on the second half of day 12.
I was getting all the right answers for the test cases, but the wrong final answer for the real test data, which was a bit miffy as that was the first wrong answer submitted.
Spent half an hour looking at the code changes for p2 which were about 5 lines, only to find the true problem was a single line route length sanity check right out of the way I put in last night when I started it and mocked up the recursive search function, and the p2 changes made routes much longer than that, but all the test data was fine.
Doh. On to day 13.
I’ve just got round to Day 6 – lanternfish. I assume it’s going to need some kind of clever coding to cater for part 2 to not make my laptop go pop?
Don't think about fish, think about where they go to learn.
You lot are clearly geeks, you'll know - Javascript, what's the best way to learn it, good beginner resources etc?
Any answer that starts with "ignore it and learn "x" instead will be given a good stiff ignoring, it's JS or nowt apparently.
Do you know any other programming languages?
And, what do you need to learn JS to do? Most of the interesting JS is using some kind of framework - you probably want to start from the right one.
Nope, complete beginner.
No idea why, it's just something they've been told they could do with learning for work. Yes, it's a very vague requirement!
I'm sure there must be a cleverer way of doing Part 2 today, but I just made a coffee whilst my workspace was running instead 🙂
@LLama - Thanks for that - it looks like it should do the job, I might even have a go myself.
I’m sure there must be a cleverer way of doing Part 2 today, but I just made a coffee whilst my workspace was running instead 🙂
I'm not even sure how to do part 1 in a reasonable amount of time
That took longer than I'd be happy telling my boss!
I'm not sure there's a quick way to search all the possibilities. I managed to get part 1 down to <1s but part 2 was about a minute to run (2019 MacBook with an i9).
Is there a clever way to do it so that it's not just crunching away?
Devised a reasonably efficient way of solving part 1, finally.
... and it only took a couple of seconds to execute for part 2, which was nice.
Huh, I'd not actually seen the common algorithm used to solve the problem before.
I'm reasonably impressed with myself that I managed to invent it for myself relatively quickly.
@euain - RGlqa3N0cmE= (base64 encoded)
My input grid is sufficiently large that I can't work out how you get a solution for part 1 that doesn't scale linearly for part 2.
Thanks - will have a play. 🙂
Happy to share my non-optimal solution if interested but I'm pretty sure this is going to be much better.
Happy to share my non-optimal solution if interested but I’m pretty sure this is going to be much better.
Yeah, if you wouldn't mind.
My initial approach was to try to brute force every possible route, which worked okay for the sample set, but failed pretty miserably for the input. Tried a few approaches around making that more efficient, but it was fairly obvious that there were just too many permutations at that scale for it to ever fly.
I've not attempted today's in just FME yet, I've completed it with FME/Python, I'm pretty sure part 1 is possible but I'm not sure I can be bothered as it will be a pain! Too much hard work understanding the puzzle today rather than actually solving it
It was a bit of a slog to work out what they were wanting. Nice wee recursive function at the end which was satisfying to see work.
Fiddly one today. I still haven't gotten part 2.
Passes the examples, and the first few params look okay (after decoding by hand), but I'm not getting the right answer :/
Oh, I missed the stupid prefix
Today was easy enough. Carried on with a slow brute-force solution (45s to solve) to part 2 but rejigged for 0.4s :).
Yeah, I just brute forced today. Wasn't proud of it.
had to put on hold now due to trying to get the stuff I'm paid for done in time for hols
might give todays a shot later
Mid dog-walk, worked out how to do part 1 with pen and paper (and managed to prove to myself there couldn't be any higher values of height that I hadn't reached). 14ms for the solution to b now :).
Finished Day 6Pt2 Lanternfish. Quite simple in the end but again, techie code issues muddied the water. Getting better tho.
Fiddly one today. Not really difficult, just some annoying code to write.
At least part 2 was trivial.
Yup, that sums it up. A bit of a slog on this one - and I managed to mess up the "get the number to the right of this one" stuff in a way I didn't spot for a while (trying to be too clever).
The folding one is still my favourite so far. (Or yesterday's one about launching drones but that's just because I managed to work out the first bit with a pen, paper and calculator - and that was being lazy).
Gosh, today's was hard work.
Today's was a bit sneaky, but went okay.
Found Sunday's bloody hard work. Plenty of chance to get thoroughly confused for me.
Relief that today's was a lot easier - though I was disappointed I didn't get a nice picture out at the end. (Or maybe I should have and my output isn't working properly?). Not sure about sneaky - they repeated "it's infinite" a few times but took a wee bit of head scratching.
Properly confused by part 2 today
Worked it out, that required a lot of thinking.
Agreed - took a bit of thinking about and my clever shortcut didn't work at all and I had to start again.
Then I was getting the wrong answer and thought it should be right. Parked it to do some proper work. Fresh eyes found I'd managed to overtype something and put a bug in my code that works out the position when you add the dice roll to your current position. Step 1 was fine - step 2 was never returning position 10. Doh..
Annoying today - mine was just about working but numbers were slightly off. In a messy bit of code I was checking a "xmin" instead of "zmin" - so my cuboids weren't as they should be! OK after that.
I really can't seem to get today's to work, I'm doing something weird with calculating a compound sum, I think.
I'm playing catchup as busy over the weekend but now away on holiday and it's peeing it down so it's keeping me occupied
I think mine's pretty solid for today so happy to supply alternate test cases / debugging scenarios if that helps.