Updated local repo
This commit is contained in:
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
count=0
|
||||
grow=0
|
||||
prev=0
|
||||
while IFS= read -r line; do
|
||||
echo $count $grow $prev
|
||||
if [ $count -eq 0 ]; then
|
||||
echo "This is the first line, we skip it (prev="$prev", line="$line")"
|
||||
prev=$line
|
||||
echo "prev=$prev, line=$line"
|
||||
|
||||
else
|
||||
if [ $line > $prev ]; then
|
||||
echo $count": "$line" > "$prev
|
||||
((grov++))
|
||||
prev=$line
|
||||
fi
|
||||
fi
|
||||
|
||||
((count++))
|
||||
done < day1_test.txt
|
||||
|
||||
echo "I can through $count lines"
|
||||
echo "I found $grov depth measurement increases"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
199
|
||||
200
|
||||
208
|
||||
210
|
||||
200
|
||||
207
|
||||
240
|
||||
269
|
||||
260
|
||||
263
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
forward 5
|
||||
down 5
|
||||
forward 8
|
||||
up 3
|
||||
down 8
|
||||
forward 2
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
00100
|
||||
11110
|
||||
10110
|
||||
10111
|
||||
10101
|
||||
01111
|
||||
00111
|
||||
11100
|
||||
10000
|
||||
11001
|
||||
00010
|
||||
01010
|
||||
@@ -0,0 +1,87 @@
|
||||
import numpy as np
|
||||
import re, sys
|
||||
|
||||
filename = open(sys.argv[1],"r")
|
||||
x = []
|
||||
xr = filename.readlines()[0].strip()
|
||||
|
||||
#print(filename.readline().rstrip())
|
||||
|
||||
#for i in filename.readlines():
|
||||
# print (i.strip())
|
||||
|
||||
|
||||
|
||||
|
||||
llist=[]
|
||||
|
||||
bingo_numbers=[]
|
||||
with open(sys.argv[1]) as f:
|
||||
# x = [ j for j in x.split() ]
|
||||
|
||||
#lines = f.readlines()
|
||||
#lines = [line.rstrip() for line in lines]
|
||||
for line in f:
|
||||
if re.search("^[0-9]+,",line.rstrip()):
|
||||
bingo_numbers = [int(i) for i in line.rstrip().split(',')]
|
||||
else:
|
||||
for x in line.rstrip().split(' '):
|
||||
if x != '':
|
||||
llist.append(x)
|
||||
|
||||
plates = len(llist)/25
|
||||
numbers=np.zeros((int(plates),5,5))
|
||||
bingo=np.zeros((int(plates),5,5))
|
||||
for l in range(0,int(plates)):
|
||||
for i in range(0,5):
|
||||
for j in range(0,5):
|
||||
numbers[l][i][j]=llist[0]
|
||||
llist.pop(0)
|
||||
#print()
|
||||
#print()
|
||||
print("----")
|
||||
print(bingo_numbers)
|
||||
|
||||
force_break = False
|
||||
called_numbers = []
|
||||
winner = []
|
||||
already_called = []
|
||||
for k in range(0,len(bingo_numbers)):
|
||||
for l in range(0,int(plates)):
|
||||
if l not in already_called:
|
||||
print('-----')
|
||||
print (l)
|
||||
print (already_called)
|
||||
print('>><<')
|
||||
if len(already_called) == int(plates)-1:
|
||||
force_break = True
|
||||
print('LAST IS NR ' + str(l))
|
||||
called_numbers.append(bingo_numbers[0])
|
||||
bingo_numbers.pop(0)
|
||||
break
|
||||
for i in range(0,5):
|
||||
for j in range(0,5):
|
||||
if numbers[l][i][j] == bingo_numbers[0]:
|
||||
bingo[l][i][j] = 1
|
||||
if sum(bingo[l][i]) == 5:
|
||||
winner = numbers[l]
|
||||
already_called.append(l)
|
||||
#print(numbers[l])
|
||||
#force_break = True
|
||||
#break
|
||||
if force_break:
|
||||
break
|
||||
|
||||
|
||||
print(called_numbers)
|
||||
print(winner)
|
||||
|
||||
winner_sum = 0
|
||||
|
||||
for i in winner:
|
||||
for j in i:
|
||||
if int(j) not in called_numbers:
|
||||
winner_sum += int(j)
|
||||
|
||||
print(winner_sum*called_numbers[-1])
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
|
||||
|
||||
22 13 17 11 0
|
||||
8 2 23 4 24
|
||||
21 9 14 16 7
|
||||
6 10 3 18 5
|
||||
1 12 20 15 19
|
||||
|
||||
3 15 0 2 22
|
||||
9 18 13 17 5
|
||||
19 8 7 25 23
|
||||
20 11 10 24 4
|
||||
14 21 16 12 6
|
||||
|
||||
14 21 17 24 4
|
||||
10 16 15 9 19
|
||||
18 8 23 26 20
|
||||
22 11 13 6 5
|
||||
2 0 12 3 7
|
||||
@@ -0,0 +1,60 @@
|
||||
import numpy as np
|
||||
import re
|
||||
import sys
|
||||
|
||||
f = open(sys.argv[1],"r")
|
||||
cords=[]
|
||||
|
||||
llist=[]
|
||||
|
||||
for line in f:
|
||||
if re.search("^[0-9]",line.rstrip()):
|
||||
for i in line.rstrip().split(' -> '):
|
||||
llist.append(i.rstrip().split(','))
|
||||
|
||||
|
||||
max_x = 0
|
||||
max_y = 0
|
||||
for i in llist:
|
||||
if int(i[0]) > max_x:
|
||||
max_x = int(i[0])
|
||||
|
||||
if int(i[1]) > max_y:
|
||||
max_y = int(i[1])
|
||||
|
||||
#field = np.zeros((int(max_y)+1,int(max_x)+1))
|
||||
field = np.zeros((1000,1000))
|
||||
|
||||
for i in range(0,len(llist)-1,2):
|
||||
x = int(llist[i][0])
|
||||
y = int(llist[i][1])
|
||||
|
||||
X = int(llist[i+1][0])
|
||||
Y = int(llist[i+1][1])
|
||||
#print('Compare ' + str(x)+','+str(y)+' and '+ str(X) + ',' + str(Y))
|
||||
if x != X and y == Y:
|
||||
if x > X:
|
||||
temp = x
|
||||
x = X
|
||||
X = temp
|
||||
print('X: Going from ' + str(x) + ' to ' + str(X))
|
||||
for j in range(x,X+1):
|
||||
field[y][j] += 1
|
||||
#print(field)
|
||||
if y != Y and x == X:
|
||||
print('Y: Going from ' + str(y) + ' to ' + str(Y))
|
||||
if y > Y:
|
||||
temp = y
|
||||
y = Y
|
||||
y = temp
|
||||
for j in range(y,Y+1):
|
||||
field[j][x] += 1
|
||||
#print(field)
|
||||
|
||||
count = 0
|
||||
|
||||
for i in field:
|
||||
for j in i:
|
||||
if int(j) >= 2: count+=1
|
||||
|
||||
print(count)
|
||||
@@ -0,0 +1,10 @@
|
||||
0,9 -> 5,9
|
||||
8,0 -> 0,8
|
||||
9,4 -> 3,4
|
||||
2,2 -> 2,1
|
||||
7,0 -> 7,4
|
||||
6,4 -> 2,0
|
||||
0,9 -> 2,9
|
||||
3,4 -> 1,4
|
||||
0,0 -> 8,8
|
||||
5,5 -> 8,2
|
||||
@@ -0,0 +1 @@
|
||||
3,4,3,1,2
|
||||
Reference in New Issue
Block a user