Author Topic: Advent of Code  (Read 115209 times)

Re: Advent of Code
« Reply #950 on: 12 December, 2020, 08:44:06 pm »
(click to show/hide)

(click to show/hide)

Re: Advent of Code
« Reply #951 on: 13 December, 2020, 08:13:20 am »
Day 13 is more about maths than programming
(click to show/hide)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: Advent of Code
« Reply #952 on: 13 December, 2020, 09:38:04 am »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #953 on: 13 December, 2020, 11:30:01 am »
Are they trying to make me learn things? Fuck that.

Re: Advent of Code
« Reply #954 on: 13 December, 2020, 12:53:51 pm »
Yep, and so this will be one of the first days with a big drop off between 1 star and 2 stars.

As I said on our internal company #advent-of-code Slack channel, today's problem is firmly over to the right of this scale:-

<------ "Programming" ----------------- "Computer Science" ---------------- "Discrete Mathematics" ------>

There's usually a good 2 or 3 each year that require something not usually covered in general "programming" or "Comp Sci".

Ob-xkcd:-

"Yes please" said Squirrel "biscuits are our favourite things."

Davef

Advent of Code
« Reply #955 on: 13 December, 2020, 12:54:07 pm »
Day 13 part 2, keeping to my terse programming, 1 loop, 1ish lines, no function calls, no Chinese takeaways.

(click to show/hide)
I seem to have smileys. How to I get rid ?

This is quite efficient. For my part 2 data it loops 1000 times which is microseconds.

Re: Advent of Code
« Reply #956 on: 13 December, 2020, 12:56:18 pm »
I seem to have smileys. How to I get rid ?

Modify the post, expand the "Additional Options" box below it, check the "Don't use smileys" checkbox.
"Yes please" said Squirrel "biscuits are our favourite things."

Davef

Re: Advent of Code
« Reply #957 on: 13 December, 2020, 01:01:19 pm »
I seem to have smileys. How to I get rid ?

Modify the post, expand the "Additional Options" box below it, check the "Don't use smileys" checkbox.
I don’t seem to have those options. I put some spaces in. Is there some [] tags you can use? Even with the extra spaces I feel I am within the 80 character limit so I can keep the source code on one punch card.

Re: Advent of Code
« Reply #958 on: 13 December, 2020, 01:41:12 pm »
Yep, and so this will be one of the first days with a big drop off between 1 star and 2 stars.

As I said on our internal company #advent-of-code Slack channel, today's problem is firmly over to the right of this scale:-

<------ "Programming" ----------------- "Computer Science" ---------------- "Discrete Mathematics" ------>

There's usually a good 2 or 3 each year that require something not usually covered in general "programming" or "Comp Sci".

Not sure I agree. It doesn’t require knowledge of that theorem and is quite computable with a fairly simple approach. Davef’s is a nice example of that.

We often see a similar pattern develop around the mid and later puzzles. The fastest and most experienced people spot a theory or solution from computer science or maths, share their observations on reddit. Others struggle for a bit, consult reddit, see lots of discussion on theorem X, and assume it is required for solution.

Eric is quite careful not to require such knowledge to derive a solution, even if it can help. We saw similar last year with the Slam Shuffle (day 22) that did allow solutions without detailed knowledge of modular arithmetic, even if it made spotting a solution easier.

Re: Advent of Code
« Reply #959 on: 13 December, 2020, 01:42:30 pm »
I don’t seem to have those options. I put some spaces in. Is there some [] tags you can use? Even with the extra spaces I feel I am within the 80 character limit so I can keep the source code on one punch card.

Are you using a browser to view the forum or something like Tapatalk?

You should be able to avoid it using code tags I guess.

Code: [Select]
Does this appear as a smiley? 8)
"Yes please" said Squirrel "biscuits are our favourite things."

Davef

Advent of Code
« Reply #960 on: 13 December, 2020, 01:57:45 pm »
If anyone is interested in how my simple solution to 13 day 2 works ...

(click to show/hide)

Re: Advent of Code
« Reply #961 on: 13 December, 2020, 02:11:20 pm »
Yep, and so this will be one of the first days with a big drop off between 1 star and 2 stars.

As I said on our internal company #advent-of-code Slack channel, today's problem is firmly over to the right of this scale:-

<------ "Programming" ----------------- "Computer Science" ---------------- "Discrete Mathematics" ------>

There's usually a good 2 or 3 each year that require something not usually covered in general "programming" or "Comp Sci".

Not sure I agree. It doesn’t require knowledge of that theorem and is quite computable with a fairly simple approach. Davef’s is a nice example of that.

We often see a similar pattern develop around the mid and later puzzles. The fastest and most experienced people spot a theory or solution from computer science or maths, share their observations on reddit. Others struggle for a bit, consult reddit, see lots of discussion on theorem X, and assume it is required for solution.

Eric is quite careful not to require such knowledge to derive a solution, even if it can help. We saw similar last year with the Slam Shuffle (day 22) that did allow solutions without detailed knowledge of modular arithmetic, even if it made spotting a solution easier.

Sure, but my point is that in pretty much every case the solutions that people come up with (like Davef's above) are just implementing simple (and/or non-optimal) cases of the underlying theorem.

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

Re: Advent of Code
« Reply #962 on: 13 December, 2020, 02:32:53 pm »
If anyone is interested in how my simple solution to 13 day 2 works ...

(click to show/hide)

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

Davef

Advent of Code
« Reply #963 on: 13 December, 2020, 02:37:41 pm »
If anyone is interested in how my simple solution to 13 day 2 works ...

(click to show/hide)

(click to show/hide)
The version I initially wrote sorted the numbers and worked largest first. It made little difference on the sample so I posted a simplified version.

Longer version with presorting (should start with step=a[0] too)
(click to show/hide)

Re: Advent of Code
« Reply #964 on: 13 December, 2020, 02:43:08 pm »
Sure, but my point is that in pretty much every case the solutions that people come up with (like Davef's above) are just implementing simple (and/or non-optimal) cases of the underlying theorem.

I agree, which is what I really like about AoC. It is possible to get those gold stars (and so not necessarily a drop-off in puzzle competitions), but the process encourages us to find out more. What better way for to introduce Theorem X by inviting us to 'discover' it via our own implementation that uses a (possibly compromised) version of it? This is pretty much the gold standard in teaching - "create" is better than "discover" is better than "show" is better than "tell".

This year's so far has been better than most in that respect. Few have been hard in the sense of preventing casual programmers from finding a solution, but many have invited further thought on ways of refining / generalising.

Re: Advent of Code
« Reply #965 on: 13 December, 2020, 02:50:57 pm »
The version I initially wrote sorted the numbers and worked largest first. It made little difference on the sample so I posted a simplified version.

Sure, but I wrote that particular pathological case specifically for the version of the algorithm you posted.

I know your algorithm would work (and be much quicker than most) for all of the example inputs within AoC but, as I've said before, I'm talking about people choosing to use AoC to learn how to solve the general case and not just get the two stars each day before moving on.

If you provided an algorithm that worked largest case first I can provide a different pathological case that will attempt to maximise runtime for that version of the algorithm.

For most problems this back and forth can be repeated again and again until the program tends to be an implementation of the optimal algorithm.

You should try the https://onlinejudge.org/ coding puzzles. The difference between AoC and those is that with the OnlineJudge ones you don't get to see the final input your program is tested against, you submit your code (in whatever language you want) for that one. The examples that are given are all quite simplistic and the input your program is actually tested on is specifically crafted to stretch the designs of most programs to the limit. It's much harder when anything less than an optimal solution just comes back with "Time exceeded, execution aborted" each time.
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #966 on: 13 December, 2020, 02:57:43 pm »

(click to show/hide)

(click to show/hide)


Re: Advent of Code
« Reply #967 on: 13 December, 2020, 03:15:45 pm »

(click to show/hide)

(click to show/hide)

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

Re: Advent of Code
« Reply #968 on: 13 December, 2020, 03:19:51 pm »
Ah, yes of course ^.

That kind of sloppy thinking on my part is why I'll never be any good at those blind coding challenges.

Re: Advent of Code
« Reply #969 on: 13 December, 2020, 04:25:57 pm »
Day 13:
https://docs.google.com/spreadsheets/d/1AqziDqaSP6ThPImbihOYHoUNlIHToVUPxhCX_A_a2ks/edit?usp=sharing

(click to show/hide)

tonycollinet

  • No Longer a western province of Númenor
Re: Advent of Code
« Reply #970 on: 13 December, 2020, 05:17:42 pm »
Well Day13 stretched my capability to logic to it's limit. My head now officially hurts. I'm in the camp of no comp_sci training, and weak engineering maths so just have to puzzle it out. ;D

Pleased I didn't look at spoilers though.

(click to show/hide)

tonycollinet

  • No Longer a western province of Númenor
Re: Advent of Code
« Reply #971 on: 13 December, 2020, 05:44:04 pm »
Lots of talk about theorems above, and now I've completed would be interested to learn more. Can anyone point out what theorem is applicable to day 13, and ideally a link to a primer of some sort.

Ta.

Re: Advent of Code
« Reply #972 on: 13 December, 2020, 06:28:27 pm »
Lots of talk about theorems above, and now I've completed would be interested to learn more. Can anyone point out what theorem is applicable to day 13, and ideally a link to a primer of some sort.

It's in this post: https://yacf.co.uk/forum/index.php?topic=94710.msg2568783#msg2568783
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #973 on: 13 December, 2020, 06:54:53 pm »
If anyone is interested in how my simple solution to 13 day 2 works ...

(click to show/hide)

(click to show/hide)

(click to show/hide)

tonycollinet

  • No Longer a western province of Númenor
Re: Advent of Code
« Reply #974 on: 13 December, 2020, 07:00:39 pm »
Lots of talk about theorems above, and now I've completed would be interested to learn more. Can anyone point out what theorem is applicable to day 13, and ideally a link to a primer of some sort.

It's in this post: https://yacf.co.uk/forum/index.php?topic=94710.msg2568783#msg2568783

Thanks - missed that in the nested spoilers :-)