Altes und aktuelles ;)

This commit is contained in:
Reiko Kaps 2021-12-01 17:01:33 +01:00
parent cc303991a9
commit bbeec8cf9f
9 changed files with 3319 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*~
*__pycache__

6
2020/01/demo.txt Normal file
View File

@ -0,0 +1,6 @@
1721
979
366
299
675
1456

200
2020/01/input.txt Normal file
View File

@ -0,0 +1,200 @@
1768
1847
1905
1713
1826
1846
1824
1976
1687
1867
1665
1606
1946
1886
1858
346
1739
1752
1700
1922
1865
1609
1617
1932
1346
1213
1933
834
1598
1191
1979
1756
1216
1820
1792
1537
1341
1390
1709
1458
1808
1885
1679
1977
1869
1614
1938
1622
1868
1844
1969
1822
1510
1994
1337
1883
1519
1766
1554
1825
1828
1972
1380
1878
1345
1469
1794
1898
1805
1911
1913
1910
1318
1862
1921
1753
1823
1896
1316
1381
1430
1962
1958
1702
1923
1993
1789
2002
1788
1970
1955
1887
1870
225
1696
1975
699
294
1605
1500
1777
1750
1857
1540
1329
1974
1947
1516
1925
1945
350
1669
1775
1536
1871
1917
1249
1971
2009
1585
1986
1701
1832
1754
1195
1697
1941
1919
2006
1667
1816
1765
1631
2003
1861
1000
1791
1786
1843
1939
1951
269
1790
1895
1355
1833
1466
1998
1806
1881
1234
1856
1619
1727
1874
1877
195
1783
1797
2010
1764
1863
1852
1841
1892
1562
1650
1942
1695
1730
1965
1632
1981
1900
1991
1884
1278
1062
1394
1999
2000
1827
1873
1926
1434
1802
1579
1879
1671
1549
1875
1838
1338
1864
1718
1800
1928
1749
1990
1705

24
2020/01/result.py Normal file
View File

@ -0,0 +1,24 @@
import collections
sum = 2020
eingabe = []
with open('./input.txt') as f:
for line in f:
eingabe.append(int(line))
# print(eingabe)
sumtable = []
for summ1 in eingabe:
suche = 2020 - summ1
sumtable.append(suche)
if suche in eingabe:
print('{} + {} = {}'.format(summ1, suche, int(summ1)+int(suche)))
print('found')
print(eingabe, len(eingabe))
print(sumtable)

28
2020/01/result2.py Normal file
View File

@ -0,0 +1,28 @@
import collections
sum = 2020
eingabe = []
with open('./input.txt') as f:
for line in f:
eingabe.append(int(line))
# print(eingabe)
sumtable = []
for summ1 in eingabe:
for summ2 in eingabe:
suche = 2020 - (summ1+summ2)
if suche in eingabe:
if suche not in sumtable:
sumtable.append(suche)
print('{} + {} + {} = {}'.format(summ1, summ2, suche, int(summ1)+int(summ2)+int(suche)))
print('found')
print(eingabe, len(eingabe))
print(sumtable)
print('{} * {} * {} = {}'.format(sumtable[0], sumtable[1], sumtable[2], sumtable[0]*sumtable[1]*sumtable[2]))

1000
2020/02/input.txt Normal file

File diff suppressed because it is too large Load Diff

40
2021/01/count_larger-02.py Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/python3
from sys import exit
larger = 0
current = -1
three = []
counter = 1
zahlen = []
with open('input.txt', 'r') as myfile:
# create a list from all lines
for lines in myfile:
zahlen.append(int(lines.strip()))
laenge = len(zahlen)
for i in range(laenge):
# stop it, if end of list is reached
if i + 2 >= laenge:
break
csum = zahlen[i] + zahlen[i+1] + zahlen[i+2]
print('{} :: {} + {} + {} = {}'.format(i, zahlen[i],zahlen[i+1],zahlen[i+2], csum))
three.append(csum)
for item in three:
if current > -1:
if item > current:
print ('current: {} < {}'.format(current, item))
larger = larger + 1
current = item
print('{} measurements are larger than the previous measurement'.format(larger))
exit

19
2021/01/count_larger.py Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/python3
larger = 0
current = -1
with open('input.txt', 'r') as myfile:
for line in myfile:
if int(line.strip()) < current:
print('{} is smaller as {}'.format(line.strip(), current))
current = int(line.strip())
else:
print('{} is larger as {}'.format(line.strip(), current))
larger = larger + 1
current = int(line.strip())
print('{} measurements are larger than the previous measurement'.format(larger - 1))

2000
2021/01/input.txt Normal file

File diff suppressed because it is too large Load Diff