You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
md5sum in the shell/awk is painfully slow.
Python solution finishes in seconds.
Version-agnostic code. Tested on Python 2.7.17 and Python 3.6.9.
PUREBASH version will test all numbers from 1, and takes +7 hours.
Copy file name to clipboardExpand all lines: 2015/README.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ https://adventofcode.com/2015/
4
4
5
5
Input can be given on the command line.
6
6
Defaults to *number*.txt in the same folder (no leading 0).
7
-
Setting env variable PUREBASH to any value (or giving a second argument) will use slow bash instead of using faster awk in days 6 and 25.
7
+
Setting env variable PUREBASH to any value (or giving a second argument) will use slow bash instead of using faster awk in days 6 and 25 and python2/3 in day 4.
8
8
9
9
### 01.sh
10
10
1. Convert brackets to ±1 and add them up.
@@ -19,7 +19,8 @@ Sort the dimensions by size. Add up the dimensions. Using a bash "bubble sort" i
19
19
20
20
### 04.sh
21
21
Oneliners using md5sum. Calling md5sum in a subshell forever to run (~150 hashes/sec). Running it from 1 could take 7-8 hours.
22
-
Speed up by setting the number to nearest 100000 below my target, skipping over 98% of the md5sum calculations.
22
+
I'm breaking all my self-imposed rules here and using python. Python version finishes both parts in 2-3 seconds (py2 is about a second slower than py3).
23
+
Optional speed up for bash by setting the number to nearest 100000 below my target, skipping over 98% of the md5sum calculations.
0 commit comments