File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ from aoc import *
2
+
3
+
4
+ def main ():
5
+ print (sum (load_ints ('1.txt' )))
6
+
7
+
8
+ main ()
Original file line number Diff line number Diff line change
1
+ def lines (path ):
2
+ """
3
+ Return a list of lines from the file `path`
4
+ """
5
+ with open (path ) as f :
6
+ return f .readlines ()
7
+
8
+
9
+ def file (path ):
10
+ """
11
+ Return contents of a file at `path` as a string
12
+ """
13
+ with open (path ) as f :
14
+ return f .read ()
15
+
16
+
17
+ def filerstrip (path ):
18
+ """
19
+ Return rstripped file contents of file at `path`
20
+ """
21
+ return file (path ).rstrip ()
22
+
23
+
24
+ def load_map (path ):
25
+ """
26
+ Return list of strings ("2D array") from the file at `path`
27
+ """
28
+ with open (path ) as f :
29
+ lines = f .readlines ()
30
+ return list (map (lambda x : x .rstrip (), lines ))
31
+
32
+
33
+ def load_ints (path ):
34
+ """
35
+ Return a list of ints loaded from file at `path`
36
+ """
37
+ with open (path ) as f :
38
+ lines = f .readlines ()
39
+ return list (map (lambda x : int (x .rstrip ()), lines ))
You can’t perform that action at this time.
0 commit comments