Author Topic: Advent of Code  (Read 111912 times)

telstarbox

  • Loving the lanes
Re: Advent of Code
« Reply #625 on: 30 November, 2018, 02:19:24 pm »
I've solved a couple of the puzzles from last year using Excel (formulae not Visual Basic) but it's clearly not the best solution for most of them. I don't know any specific programming languages so would you recommend any particular one for having a go at this year's puzzles?
2019 🏅 R1000 and B1000

Re: Advent of Code
« Reply #626 on: 30 November, 2018, 03:51:42 pm »
If all programming languages are new to you, I think the best choice would be the one you would most like to learn. Most are going to be languages that at least could be used to answer the AoC challenges, so really it's about what might motivate you to learn any one of them.

Some common candidates would be Python (probably the sweet spot between ease of learning and suitability for AoC-type questions), Javascript (or one of its variants such as Typescript) and Java. But there are plenty more to chose from (someone in the last couple of years set themselves the challenges of using a different language for every question - that's 50 over two years! But not something I would recommend unless you have a lot of time on your hands and feel the need to have programmed in 50 languages).

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: Advent of Code
« Reply #627 on: 30 November, 2018, 05:19:27 pm »
VBA is a perfectly decent programming language for tasks at this level, why not just use that as you have it available?  Most other languages will have a learning curve associated with the tools, excel VBA is about as simple as it gets in that respect. Plus excel formulae are well suited to some puzzles, use whatever works best for each and keep it all together in one file.  You'll soon start subliminally learning about code re-use too.

Aside: addictive innit.
2023 targets: Survive. Maybe.
There is only one infinite resource in this universe; human stupidity.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #628 on: 02 December, 2018, 02:16:14 pm »
It has started off gently enough though the part twos are a bit more complex than typical from previous years. I am left thinking there must be a better/more efficient way to solve some of them.
"By creating we think. By living we learn" - Patrick Geddes

Ben T

Re: Advent of Code
« Reply #629 on: 02 December, 2018, 05:29:12 pm »
Day 1 part 2 looks like there might be a Dynamic Programming solution but I can't see exactly what it is at the moment.

vorsprung

  • Opposites Attract
    • Audaxing
Re: Advent of Code
« Reply #630 on: 02 December, 2018, 05:30:07 pm »
Did day 1 and 2 with perl one liners.  Although the second part of day 2 was a bit long

Not sure if ICBA to carry on with this :)

Re: Advent of Code
« Reply #631 on: 02 December, 2018, 06:23:53 pm »
Did day 1 and 2 with perl one liners.  Although the second part of day 2 was a bit long

Not sure if ICBA to carry on with this :)

You can join the YACF leaderboard with the code 48462-ea506236. And it does get quite addictive (and the puzzles more varied).

Re: Advent of Code
« Reply #632 on: 02 December, 2018, 08:35:13 pm »
Caught up with day 1 and 2 now I'm back from a weekend away. Nice gentle start.

(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

vorsprung

  • Opposites Attract
    • Audaxing
Re: Advent of Code
« Reply #633 on: 02 December, 2018, 08:46:21 pm »
Jo,

I am anonymous user #241788  apparently

Re: Advent of Code
« Reply #634 on: 02 December, 2018, 09:00:50 pm »
Jo left here a long time ago.

Forgot to say, now that it has started I can now legitimately wear my AoC t-shirt.
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #635 on: 03 December, 2018, 10:07:45 am »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #636 on: 04 December, 2018, 09:50:11 pm »
Is it just me or are they quite involved with no obvious 'simple algorithm'? Day 4 took me a while - not difficult, just involved.

(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Ben T

Re: Advent of Code
« Reply #637 on: 04 December, 2018, 11:45:44 pm »
Yes, not a difficult algorithm but like you say involved. https://github.com/bjtaylor1/AoC2018/blob/master/Day04/Program.cs (link contains spoiler). Didn't take long but I did use classes where I normally wouldn't have to bother.

Re: Advent of Code
« Reply #638 on: 05 December, 2018, 09:35:29 am »
Day 4 wasn't about a specific algorithm, it was just about using appropriate data structures for the job. The better choice of data structure the easier it would be to implement the solution.

That and...
(click to show/hide)

With some of the puzzles there's usually only one (high-level) algorithm that will work in a reasonable time frame, and certainly only one (high-level) algorithm that would work if the input was considerably larger (which would show up the inefficient algorithm choices).

There's a number of different ways that you could have approached day 4, all perfectly valid.

I guess it highlights the fact that it's important to know when to optimise something, or choose to correct algorithm, and when you can just get away with anything that works.
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #639 on: 05 December, 2018, 11:09:01 am »
(click to show/hide)

Re: Advent of Code
« Reply #640 on: 05 December, 2018, 02:44:42 pm »
Ooh, if we're doing timings...

(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #641 on: 05 December, 2018, 03:09:35 pm »
Hmm. Interesting. Code?
Only reason I'm curious is if single threaded, I would have expected 5.2 to take 26 times as long as 5.1. Your perl solution did, but C took only 11 times longer, so are you doing some sort of BFS/DFS type search?

Re: Advent of Code
« Reply #642 on: 05 December, 2018, 04:51:24 pm »
There's an initial cost to parsing the input string which will mean part 2 won't take exactly 26 times as long as the first.

Code and comments:
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

telstarbox

  • Loving the lanes
Re: Advent of Code
« Reply #643 on: 05 December, 2018, 05:15:06 pm »
For day 1 part 2 - do you need to use more than one loop of the input text? It's confusing me lots!
2019 🏅 R1000 and B1000

Re: Advent of Code
« Reply #644 on: 05 December, 2018, 06:58:29 pm »
For day 1 part 2 - do you need to use more than one loop of the input text? It's confusing me lots!

"
Note that your device might need to repeat its list of frequency changes many times before a duplicate frequency is found, and that duplicates might be found while in the middle of processing the list.
"
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #645 on: 05 December, 2018, 08:32:27 pm »
My code for day 5 is obviously inefficient (it does a lot of string allocation) in Python
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #646 on: 05 December, 2018, 09:04:47 pm »
(click to show/hide)
Quote from: tiermat
that's not science, it's semantics.

Re: Advent of Code
« Reply #647 on: 06 December, 2018, 09:08:15 am »
Day 6 was nicely different.

(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #648 on: 06 December, 2018, 11:23:56 am »
Day 6 is interesting, weirdly I found part 1 harder than part 2.
(click to show/hide)


Re: Advent of Code
« Reply #649 on: 06 December, 2018, 11:41:39 am »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."