mirror of
https://github.com/bvanroll/advent-of-code-2020.git
synced 2025-08-29 03:52:47 +00:00
lesgo
This commit is contained in:
15
06/example.txt
Normal file
15
06/example.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
abc
|
||||||
|
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
|
||||||
|
ab
|
||||||
|
ac
|
||||||
|
|
||||||
|
a
|
||||||
|
a
|
||||||
|
a
|
||||||
|
a
|
||||||
|
|
||||||
|
b
|
2165
06/input.txt
Normal file
2165
06/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
51
06/main.py
Normal file
51
06/main.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# python again :^P
|
||||||
|
import string
|
||||||
|
|
||||||
|
|
||||||
|
groups = []
|
||||||
|
lines = open("input.txt").read().split("\n")
|
||||||
|
groupIndex = 0
|
||||||
|
personIndex = 0
|
||||||
|
|
||||||
|
tline = ""
|
||||||
|
|
||||||
|
tObject = {}
|
||||||
|
tIndex = 0
|
||||||
|
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if len(line) == 0:
|
||||||
|
if len(tObject.keys()) > 0:
|
||||||
|
groups.append(tObject)
|
||||||
|
tObject = {}
|
||||||
|
tIndex = 0
|
||||||
|
continue
|
||||||
|
tObject[tIndex] = line
|
||||||
|
tIndex += 1
|
||||||
|
|
||||||
|
|
||||||
|
#print(groups)
|
||||||
|
|
||||||
|
groups.append(tline)
|
||||||
|
|
||||||
|
def scoreGroup(group):
|
||||||
|
gscore = 0
|
||||||
|
qs = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
if isinstance(group, str):
|
||||||
|
#print("this one is a str for some reason, so score 0")
|
||||||
|
return gscore
|
||||||
|
|
||||||
|
for char in qs:
|
||||||
|
valid = True
|
||||||
|
for key in group.keys():
|
||||||
|
if char not in group[key]:
|
||||||
|
valid = False
|
||||||
|
if valid:
|
||||||
|
gscore += 1
|
||||||
|
return gscore
|
||||||
|
|
||||||
|
score = 0
|
||||||
|
for group in groups:
|
||||||
|
score += scoreGroup(group)
|
||||||
|
|
||||||
|
print(score)
|
32
06/task1.py
Normal file
32
06/task1.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# python again :^P
|
||||||
|
import string
|
||||||
|
|
||||||
|
|
||||||
|
groups = []
|
||||||
|
lines = open("input.txt").read().split("\n")
|
||||||
|
groupIndex = 0
|
||||||
|
personIndex = 0
|
||||||
|
|
||||||
|
tline = ""
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
tline += line
|
||||||
|
if len(line) == 0:
|
||||||
|
groups.append(tline)
|
||||||
|
tline = ""
|
||||||
|
|
||||||
|
groups.append(tline)
|
||||||
|
|
||||||
|
def scoreGroup(group):
|
||||||
|
gscore = 0
|
||||||
|
qs = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
for char in qs:
|
||||||
|
if char in group:
|
||||||
|
gscore += 1
|
||||||
|
return gscore
|
||||||
|
|
||||||
|
score = 0
|
||||||
|
for group in groups:
|
||||||
|
score += scoreGroup(group)
|
||||||
|
|
||||||
|
print(score)
|
@@ -2,3 +2,8 @@
|
|||||||
Guessing my way through advent of code 2020
|
Guessing my way through advent of code 2020
|
||||||
Also, i'm going to "make this harder" for myself by picking a different coding language each day. Or at least trying to.
|
Also, i'm going to "make this harder" for myself by picking a different coding language each day. Or at least trying to.
|
||||||
:^)
|
:^)
|
||||||
|
|
||||||
|
|
||||||
|
## update
|
||||||
|
so yea, i gave up on the different coding languages for now. I dont have the time to look up syntax all day and work.
|
||||||
|
And when i'm not working, i really try to enjoy my me-time. so for now, it's python only
|
||||||
|
Reference in New Issue
Block a user