advent-of-code-2017 | Code 2017 edition by Jeroen Heijmans | Learning library
kandi X-RAY | advent-of-code-2017 Summary
kandi X-RAY | advent-of-code-2017 Summary
Solutions to the Advent of Code 2017 edition by Jeroen Heijmans.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of advent-of-code-2017
advent-of-code-2017 Key Features
advent-of-code-2017 Examples and Code Snippets
Community Discussions
Trending Discussions on advent-of-code-2017
QUESTION
Problem Description: I am trying to do the task mentioned here - https://codereview.stackexchange.com/questions/182483/advent-of-code-2017-day-1-sum-of-digits-matching-the-next-digit-circular-list
But in Windows Power Shell using simple loop logic (as I am new to Power Shell)
The task requires to review a sequence of digits and find the sum of all digits that match the next digit in the list. The list is circular, so the digit after the last digit is the first digit in the list. For example:
1122 produces a sum of 3 (1 + 2) because the first digit 1 matches the second digit and the third digit 2 matches the fourth digit; 1111 produces 4 because each digit (all 1) matches the next; 1234 produces 0 because no digit matches the next; 91212129 produces 9 because the only digit that matches the next one is the last digit, 9
I have coded this:
...ANSWER
Answered 2018-May-17 at 19:22The var $i iterates through the Length,
Edit streamlined version thank to a hint from BenH
QUESTION
I've started leaning Haskell not long ago by solving this year's Advent of Code tasks.
While solving Part 2 of Day 17 I've ran into a nasty memory leak (space leak) -- I think.
(Here's the full README including Part 2, one can only access it after solving Part 1.)
My solution works and it runs fine, but only with a dirty little hack, which forces Haskell to evaluate an intermediate computation every now and then.
I'm using traceShow
to print the intermediate state to the console after every 5000 iterations (please see here the actual code). This way the program finishes in a reasonable time and doesn't use too much memory.
The problem: if I remove this (not printing the intermediate state at all, only the last state) the program eats up all available memory. :(
I've started out with using iterate
and then I've read that using that can cause stuff like what I'm noticing. I've replaced it. Nothing. Tried different folds (foldl
, foldl'
, etc.). Nothing. I'm not sure at this point what can cause this although my guess is that at some point there's some not so evident lazy evaluation going on.
My question: how can I avoid this? What causes this in my case?
Thank you for your time and insight. Oh, and I'm pretty sure that there are shorter, sweeter solutions to this problem, but currently I'm only interested in what causes the memory leak in my case.
TestingI've isolated the part of the code where I notice this error.
...ANSWER
Answered 2017-Dec-30 at 14:59The following works:
QUESTION
New to Perl6, trying to figure out what I'm doing wrong here. The problem is a simple checksum that takes the difference of the max and min values for each row in the csv
The max and min values it returns are completely wrong. For the first row in the csv, it returns the max as 71, and the min as 104, which is incorrect.
Here's the link to the repo for reference, and the link to the corresponding problem.
...ANSWER
Answered 2017-Dec-05 at 04:26I assume your input contains numbers, but since CSV is a text format, the input is being read in as strings. min
and max
are operating based on string sorting, so max("4", "10")
is 4
but max("04", "10")
is 10
. To solve this, you can either cast each element to Numeric
(int, floating point, etc.) before you get the min/max:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install advent-of-code-2017
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page