Author Topic: Advent of Code  (Read 111508 times)

Re: Advent of Code
« Reply #425 on: 07 December, 2017, 11:41:07 am »
Day 7:

(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 #426 on: 07 December, 2017, 01:21:28 pm »
Day 7:

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

Re: Advent of Code
« Reply #427 on: 07 December, 2017, 01:41:31 pm »
Day 7:

(click to show/hide)

(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 #428 on: 07 December, 2017, 01:47:42 pm »
That reminds me of the reddit competition to find the most ridiculous way to test if a number was even or odd.
It is order(N) for every lookup, making it approach order (N^2) overall.

(click to show/hide)

"By creating we think. By living we learn" - Patrick Geddes

Ben T

Re: Advent of Code
« Reply #429 on: 07 December, 2017, 02:07:42 pm »
did it in a probably over verbose OO way https://github.com/bjtaylor1/AoC2017/blob/day07part2/Day07/App.cs but didn't take long and was basically shot from the hip and didn't require any debugging to get right pretty much first time

Re: Advent of Code
« Reply #430 on: 07 December, 2017, 02:41:40 pm »
Day 7:

(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 #431 on: 07 December, 2017, 04:10:34 pm »
OK, here is my python
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #432 on: 07 December, 2017, 04:15:17 pm »
Day 7:

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

Re: Advent of Code
« Reply #433 on: 07 December, 2017, 05:20:46 pm »
can you not (instead of the two cases) do:

Almost certainly, but that file was pretty much the first thing that gave me the correct answer (whether it prints it explicitly like mine, or gives enough information to work out the answer like yours). I don't bother polishing it once I've submitted a correct answer. If I was going to use it for anything else in the future then I'd spend some time refactoring it and adding suitable comments. I'd also consider how it would handle much larger inputs.

The last thing I want to be doing is chasing bugs in the code that reads the input, so I've no problem with a bit of duplication there.

[EDIT] It's only when the problems start to get properly challenging that I will take more care on my programs. My goal is to get the answer as quickly as possible (and in a reasonable execution time). The competition is not really making me learn anything new (if you want that then the Valladolid Online Judge or Project Euler are much better).
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #434 on: 07 December, 2017, 09:48:05 pm »
My goodness I made a meal out of that one. Must remember to read the question properly  :facepalm:
Quote from: tiermat
that's not science, it's semantics.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #435 on: 07 December, 2017, 10:49:09 pm »
Thanks for the links to Project Euler and the Valladolid Judge sites. Interesting challenges though the sites are not terribly clear on how they work.
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #436 on: 07 December, 2017, 10:58:36 pm »
Valladolid was submit your code by email (at least when I was doing it back in 2001!). The automated system then sanitised it (to make sure you weren't doing anything silly or destructive) and then ran the code against an unseen input.

Their trick was the example inputs you got given on the website were a fraction of the size of the real input (which you never saw), or the real input was the pathological case for the standard algorithm.

So many times I'd be confident about my code, email it off, only to receive a "Time Limit Exceeded" response.

Can't remember much about Project Euler, only did one or two but I discussed a lot of the problems with someone from work I was mentoring.

Day 8: Will it be another fake CPU question (I do like them) or something like a knapsack or another TSP-esque classic?
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #437 on: 07 December, 2017, 11:06:44 pm »
We have had the first tree traversal one. Must be some magic codes to parse (medicine for rudolf). Still in early days so shouldn't be too taxing (hostage to fortune there).
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #438 on: 07 December, 2017, 11:11:19 pm »
Day 7
Solved with a spreadsheet. It did get quite big but not as large as many I written that have a more serious purpose.
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #439 on: 07 December, 2017, 11:34:22 pm »
I cannot imagine voluntarily choosing to do it that way. It makes me cringe even thinking about it.
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #440 on: 07 December, 2017, 11:50:43 pm »
Day 7 p2 is still not done.

RL has got in the way -- I can see two ways of attacking it, both of which should work, but haven had the time yet to give either a go.

(click to show/hide)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #441 on: 08 December, 2017, 12:01:05 am »
Recursion works when recursion works.
What is the non-recursive approach?
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #442 on: 08 December, 2017, 06:18:02 am »
I cannot imagine voluntarily choosing to do it that way. It makes me cringe even thinking about it.

There towers are only 6 levels high, so finding a group of formulas that works, and copying across until there are no more sub-towers doesn't take long
The spreadsheet was 6000 lines long, as each step ended up at 9 lines. In retrospect 10 would have been easier on the brain.
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: Advent of Code
« Reply #443 on: 08 December, 2017, 06:20:41 am »
Day 8 didn't seem all that difficult.
(click to show/hide)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #444 on: 08 December, 2017, 07:41:36 am »
Pretty much
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #445 on: 08 December, 2017, 09:38:23 am »
Day 8:

(click to show/hide)

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

Ben T

Re: Advent of Code
« Reply #446 on: 08 December, 2017, 10:53:29 am »
self contained dynamic compilation https://github.com/bjtaylor1/AoC2017/blob/day08part2/Day08/Program.cs
essentially the same, my TranslateCode function is your line of sed and my main function is orchestrating the running of it.

Re: Advent of Code
« Reply #447 on: 08 December, 2017, 02:00:05 pm »
Day 8: Will it be another fake CPU question (I do like them) or something like a knapsack or another TSP-esque classic?

And, lo, it was a fake CPU type question.

I wrote an interpreter for my solution before doing the above horrific command line transpose nonsense.

Will we get a couple of biggies to do over the weekend? I hope so!
"Yes please" said Squirrel "biscuits are our favourite things."

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #448 on: 08 December, 2017, 04:08:02 pm »
Finally got round to doing day 7 part 2.  (after knocking out day 8 )

(click to show/hide)

(click to show/hide)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

Ben T

Re: Advent of Code
« Reply #449 on: 08 December, 2017, 04:42:47 pm »
(click to show/hide)