first commit
This commit is contained in:
16
2017/1.py
Executable file
16
2017/1.py
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
#a = "7385764686251444473997915123782972536343732657517834671759462795461213782428342931896181695578996274321317419242359534783957372932953774336338118488967172727651862498838195317654289797558683458511126996217953322817229372373455862177844478443391835484591525235651863464891177927244954925827786799436536592561374269299474738321293575385899438446558569241236278779779983587912431395475244796538888373287186921647426866237756737342731976763959499149996315591584716122199183295277439872911371313924594486766479438544417416529743495114819825984524437367225234184772617942525954961136976875325182725754768372684531972614455134523596338355374444273522115362238734383164778129376628621497662965456761631796178353599629887665939521892447361219479646483978798392716119793282717739524897385958273726776318154977675546287789874265339688753977185129334929715486381875286278528247696464162297691698154712775589541945263574897266575996455547625537947927972497979333932115165151462742216327321116291372396585618664475715321298122335789262942284571328414569375464386446824882551918843185195829547373915482687534432942778312542752798313434628498295216692646713137244198123219531693559848915834623825919191532658735422176965451741869666714874158492556445954852299161868651448123825821775363219246244515946392686275545561989355573946924767442253465342753995764791927951158771231944177692469531494559697911176613943396258141822244578457498361352381518166587583342233816989329544415621127397996723997397219676486966684729653763525768655324443991129862129181215339947555257279592921258246646215764736698583211625887436176149251356452358211458343439374688341116529726972434697324734525114192229641464227986582845477741747787673588848439713619326889624326944553386782821633538775371915973899959295232927996742218926514374168947582441892731462993481877277714436887597223871881149693228928442427611664655772333471893735932419937832937953495929514837663883938416644387342825836673733778119481514427512453357628396666791547531814844176342696362416842993761919369994779897357348334197721735231299249116477"
|
||||
|
||||
|
||||
a = "738576468625144447"
|
||||
|
||||
|
||||
#print vhod[1]
|
||||
|
||||
from operator import eq
|
||||
print sum(map(eq, a, a[1:])) + (int(a[0]) if int(a[0]) == int(a[-1]) else 0)
|
||||
print map(eq, a, a[1:])
|
||||
|
||||
|
30
2017/2.py
Executable file
30
2017/2.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
import csv
|
||||
|
||||
crimefile = open('input2.txt', 'r')
|
||||
#ireader = csv.reader(crimefile)
|
||||
allRows = [line.strip('\n').split('\t') for line in crimefile.readlines()]
|
||||
|
||||
|
||||
|
||||
|
||||
chk = 0
|
||||
|
||||
for line in allRows:
|
||||
hi = max([int(i) for i in line])
|
||||
lo = min([int(i) for i in line])
|
||||
chk = chk + (hi-lo)
|
||||
|
||||
print chk
|
||||
|
||||
chk = 0
|
||||
for line in allRows:
|
||||
hi = max([int(i) for i in line])
|
||||
lo = min([int(i) for i in line])
|
||||
chk = chk + (hi-lo)
|
||||
|
||||
print chk
|
||||
|
||||
|
24
2017/alt1.py
Executable file
24
2017/alt1.py
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
myfile = open('input.txt', 'r')
|
||||
contents = myfile.read()
|
||||
myfile.close()
|
||||
|
||||
contents = contents.strip()
|
||||
|
||||
part_one = 0
|
||||
part_two = 0
|
||||
|
||||
for i in range(len(contents) - 1):
|
||||
if contents[i] == contents[i + 1]:
|
||||
part_one += int(contents[i])
|
||||
|
||||
if contents[-1] == contents[0]:
|
||||
part_one += int(contents[-1])
|
||||
|
||||
for i in range(len(contents)):
|
||||
if contents[i] == contents[int(i + len(contents) / 2) % len(contents)]:
|
||||
part_two += int(contents[i])
|
||||
|
||||
print("Part One:", part_one)
|
||||
print("Part Two:", part_two)
|
27
2017/alt2.py
Normal file
27
2017/alt2.py
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import itertools
|
||||
|
||||
with open('input2.txt') as f:
|
||||
data = []
|
||||
for line in f.read().splitlines():
|
||||
data.append(list(map(int, line.split())))
|
||||
|
||||
def part1():
|
||||
checksum = 0
|
||||
for row in data:
|
||||
checksum += max(row) - min(row)
|
||||
return checksum
|
||||
|
||||
def part2():
|
||||
checksum = 0
|
||||
for row in data:
|
||||
combos = list(itertools.combinations(row, 2))
|
||||
for c in combos:
|
||||
a, b = max(c), min(c)
|
||||
if a % b == 0:
|
||||
checksum += a//b
|
||||
return checksum
|
||||
|
||||
print(part1())
|
||||
print(part2())
|
1
2017/input.txt
Normal file
1
2017/input.txt
Normal file
@ -0,0 +1 @@
|
||||
7385764686251444473997915123782972536343732657517834671759462795461213782428342931896181695578996274321317419242359534783957372932953774336338118488967172727651862498838195317654289797558683458511126996217953322817229372373455862177844478443391835484591525235651863464891177927244954925827786799436536592561374269299474738321293575385899438446558569241236278779779983587912431395475244796538888373287186921647426866237756737342731976763959499149996315591584716122199183295277439872911371313924594486766479438544417416529743495114819825984524437367225234184772617942525954961136976875325182725754768372684531972614455134523596338355374444273522115362238734383164778129376628621497662965456761631796178353599629887665939521892447361219479646483978798392716119793282717739524897385958273726776318154977675546287789874265339688753977185129334929715486381875286278528247696464162297691698154712775589541945263574897266575996455547625537947927972497979333932115165151462742216327321116291372396585618664475715321298122335789262942284571328414569375464386446824882551918843185195829547373915482687534432942778312542752798313434628498295216692646713137244198123219531693559848915834623825919191532658735422176965451741869666714874158492556445954852299161868651448123825821775363219246244515946392686275545561989355573946924767442253465342753995764791927951158771231944177692469531494559697911176613943396258141822244578457498361352381518166587583342233816989329544415621127397996723997397219676486966684729653763525768655324443991129862129181215339947555257279592921258246646215764736698583211625887436176149251356452358211458343439374688341116529726972434697324734525114192229641464227986582845477741747787673588848439713619326889624326944553386782821633538775371915973899959295232927996742218926514374168947582441892731462993481877277714436887597223871881149693228928442427611664655772333471893735932419937832937953495929514837663883938416644387342825836673733778119481514427512453357628396666791547531814844176342696362416842993761919369994779897357348334197721735231299249116477
|
16
2017/input2.txt
Normal file
16
2017/input2.txt
Normal file
@ -0,0 +1,16 @@
|
||||
278 1689 250 1512 1792 1974 175 1639 235 1635 1690 1947 810 224 928 859
|
||||
160 50 55 81 68 130 145 21 211 136 119 78 174 155 149 72
|
||||
4284 185 4499 273 4750 4620 4779 4669 2333 231 416 1603 197 922 5149 2993
|
||||
120 124 104 1015 1467 110 299 320 1516 137 1473 132 1229 1329 1430 392
|
||||
257 234 3409 2914 2993 3291 368 284 259 3445 245 1400 3276 339 2207 233
|
||||
1259 78 811 99 2295 1628 3264 2616 116 3069 2622 1696 1457 1532 268 82
|
||||
868 619 139 522 168 872 176 160 1010 200 974 1008 1139 552 510 1083
|
||||
1982 224 3003 234 212 1293 1453 3359 326 3627 3276 3347 1438 2910 248 2512
|
||||
4964 527 5108 4742 4282 4561 4070 3540 196 228 3639 4848 152 1174 5005 202
|
||||
1381 1480 116 435 980 1022 155 1452 1372 121 128 869 1043 826 1398 137
|
||||
2067 2153 622 1479 2405 1134 2160 1057 819 99 106 1628 1538 108 112 1732
|
||||
4535 2729 4960 241 4372 3960 248 267 230 5083 827 1843 3488 4762 2294 3932
|
||||
3245 190 2249 2812 2620 2743 2209 465 139 2757 203 2832 2454 177 2799 2278
|
||||
1308 797 498 791 1312 99 1402 1332 521 1354 1339 101 367 1333 111 92
|
||||
149 4140 112 3748 148 815 4261 138 1422 2670 32 334 2029 4750 4472 2010
|
||||
114 605 94 136 96 167 553 395 164 159 284 104 530 551 544 18
|
Reference in New Issue
Block a user