File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #Advent of code 2021
2
+ # 1/11/22 day 8a
3
+ # Joe McFarland
4
+ # import sys
5
+ # import re
6
+ # import copy
7
+ filename = "data8.txt"
8
+
9
+ def isMatch (word ):
10
+ # match word:
11
+ # case "fg":
12
+ match len (word ):
13
+ case 2 : # num 1
14
+ return True
15
+ case 4 : # num 4
16
+ return True
17
+ case 3 : # num 7
18
+ return True
19
+ case 7 : # num 8
20
+ return True
21
+ return False
22
+
23
+
24
+ file = open (filename )
25
+ filestr = file .read ()
26
+ a_list = filestr .split ("\n " )
27
+ maxrows = len (a_list )
28
+ #print(a_list)
29
+ #maxcols = len(a_list[0])
30
+ count = 0
31
+ for line in a_list :
32
+ a_str = line .split (" | " )
33
+ sig_str = a_str [0 ]
34
+ out_str = a_str [1 ]
35
+ print (f"{ sig_str } , { out_str } " )
36
+ out_list = out_str .split ()
37
+ for word in out_list :
38
+ if isMatch (word ):
39
+ count += 1
40
+ print (f"count={ count } " )
41
+
You can’t perform that action at this time.
0 commit comments