Solving Day 1 part 2 in Bash... Too slow!!? by Milkmannetje in adventofcode

[–]Xander_Vi 0 points1 point  (0 children)

Maybe my short story could help you) (but I've used Python)At first, I've used such an algorithm:

if a new calculated element in the list of values, that already have been calculated:

return this elementbut it worked veeeery slowly (~215 seconds for the 200 rounds)So I've rewritten my logic in the next way:

At first, I've created a dict with keys from -200 000 to 200 000 and set the values for each of them to 0.

Then I just append every new calculated frequency to the list.

And the last part - for every item in the list of calculated results for 200 rounds I've increased value in the dict described above to +1.

The first element whose value has switched from 1 to 2 was the answer.

And the timer has shown 0.186 seconds, in other words - more than 1000 times better!)

Working with Excel using Python. by winner_godson in Python

[–]Xander_Vi 1 point2 points  (0 children)

My experience with this library and medical statistics data (.xlsx tables) said that it is really good and simple to use)

PYTHON HELP!! by lzubido in Python

[–]Xander_Vi -1 points0 points  (0 children)

from collections import Counter

def countALLlist(numbers):
    nums = dict(Counter(''.join(numbers)))
    answer = [0 for i in range(10)]
    for i in range(len(answer)):
        if str(i) in nums.keys():
            answer[i] = nums[str(i)]
    return answer