Compare commits
No commits in common. "b3809fabc76370b8d1c46b9224f23693a55e022b" and "980acef7625b66d85cd5a6f64f7188c5df508556" have entirely different histories.
b3809fabc7
...
980acef762
@ -1,40 +0,0 @@
|
|||||||
#!/bin/python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
input_f = sys.argv[1]
|
|
||||||
|
|
||||||
result = 0
|
|
||||||
|
|
||||||
with open(input_f) as file:
|
|
||||||
for line in file:
|
|
||||||
tmp = line.rstrip()
|
|
||||||
print(tmp)
|
|
||||||
vowel_count = 0
|
|
||||||
t = ['ab','cd','pq','xy']
|
|
||||||
first = False
|
|
||||||
second = False
|
|
||||||
for i in t:
|
|
||||||
if tmp.find(i) != -1:
|
|
||||||
print(" is naughty because it contains " + i)
|
|
||||||
first = True
|
|
||||||
break
|
|
||||||
f = 'aeiou'
|
|
||||||
for idx,i in enumerate(tmp):
|
|
||||||
if idx+1 < len(tmp) and first == False:
|
|
||||||
#print(idx,idx+1,len(tmp))
|
|
||||||
if i == tmp[idx+1]:
|
|
||||||
second = True
|
|
||||||
if second == False and first == False:
|
|
||||||
print("naughte cus no double")
|
|
||||||
for idx,i in enumerate(tmp):
|
|
||||||
if f.find(i) != -1 and second == True and first == False:
|
|
||||||
vowel_count += 1
|
|
||||||
if vowel_count == 3:
|
|
||||||
print(" is nice because it contains " + str(vowel_count) + " vowels and double letters")
|
|
||||||
result += 1
|
|
||||||
if second == True and vowel_count < 3:
|
|
||||||
print("naughty cus " + str(vowel_count) + " vowels")
|
|
||||||
print()
|
|
||||||
print(result)
|
|
@ -1,49 +0,0 @@
|
|||||||
import sys
|
|
||||||
from pprint import pprint
|
|
||||||
import re
|
|
||||||
from itertools import product
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
instructions = []
|
|
||||||
|
|
||||||
with open(sys.argv[1]) as file:
|
|
||||||
tmp = []
|
|
||||||
for line in file:
|
|
||||||
tmp = [re.match(r'.+?(?=\d)',line).group().strip()]
|
|
||||||
tmp += [int(i) for i in re.findall(r'\d+',line)]
|
|
||||||
instructions.append(tmp)
|
|
||||||
|
|
||||||
size = 1000
|
|
||||||
|
|
||||||
maps = defaultdict(bool)
|
|
||||||
#maps = [ [False]*size for i in range(size)]
|
|
||||||
|
|
||||||
|
|
||||||
for i in instructions:
|
|
||||||
for x in product(range(i[1],i[3]+1),range(i[2],i[4]+1)):
|
|
||||||
if i[0] == 'turn off':
|
|
||||||
maps[x] = False
|
|
||||||
elif i[0] == 'turn on':
|
|
||||||
maps[x] = True
|
|
||||||
else:
|
|
||||||
if maps[x] == True:
|
|
||||||
maps[x] = False
|
|
||||||
else:
|
|
||||||
maps[x] = True
|
|
||||||
|
|
||||||
#for y in range(i[1],i[3]+1):
|
|
||||||
# for x in range(i[2],i[4]+1):
|
|
||||||
# if i[0] == 'turn off':
|
|
||||||
# maps[x][y] = False
|
|
||||||
# elif i[0] == 'turn on':
|
|
||||||
# maps[x][y] = False
|
|
||||||
# else:
|
|
||||||
# maps[x][y] = True if maps[x][y] == False else maps[x][y] == True
|
|
||||||
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
for i in product(range(0,size),range(0,size)):
|
|
||||||
if maps[i] == True:
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
print(count)
|
|
@ -1,35 +0,0 @@
|
|||||||
import sys
|
|
||||||
from pprint import pprint
|
|
||||||
import re
|
|
||||||
from itertools import product
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
instructions = []
|
|
||||||
|
|
||||||
with open(sys.argv[1]) as file:
|
|
||||||
tmp = []
|
|
||||||
for line in file:
|
|
||||||
tmp = [re.match(r'.+?(?=\d)',line).group().strip()]
|
|
||||||
tmp += [int(i) for i in re.findall(r'\d+',line)]
|
|
||||||
instructions.append(tmp)
|
|
||||||
|
|
||||||
size = 1000
|
|
||||||
|
|
||||||
maps = defaultdict(int)
|
|
||||||
|
|
||||||
for i in instructions:
|
|
||||||
for x in product(range(i[1],i[3]+1),range(i[2],i[4]+1)):
|
|
||||||
if i[0] == 'turn off':
|
|
||||||
if maps[x] != 0:
|
|
||||||
maps[x] -= 1
|
|
||||||
elif i[0] == 'turn on':
|
|
||||||
maps[x] += 1
|
|
||||||
else:
|
|
||||||
maps[x] += 2
|
|
||||||
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
for i in product(range(0,size),range(0,size)):
|
|
||||||
count += maps[i]
|
|
||||||
|
|
||||||
print(count)
|
|
Loading…
Reference in New Issue
Block a user