Compare commits
2 Commits
f6d06f1ffa
...
460f79b618
Author | SHA1 | Date |
---|---|---|
kwout | 460f79b618 | 2 years ago |
kwout | 488f7796da | 2 years ago |
6 changed files with 397 additions and 0 deletions
@ -0,0 +1,61 @@ |
||||
entries = open("input.txt", 'r').read().splitlines() |
||||
|
||||
summa = 0 |
||||
count = 0 |
||||
for e in entries: |
||||
digits = e.split(" | ")[0].split() |
||||
output = e.split(" | ")[1].split() |
||||
dic = [set() for i in range(10)] |
||||
counts = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0} |
||||
for s in digits: |
||||
if len(s) == 4: |
||||
dic[4].update(set(s)) |
||||
elif len(s) == 2: |
||||
dic[1].update(set(s)) |
||||
elif len(s) == 3: |
||||
dic[7].update(set(s)) |
||||
elif len(s) == 7: |
||||
dic[8].update(set(s)) |
||||
for l in s: |
||||
counts[l] += 1 |
||||
for l in counts: |
||||
if counts[l] == 9: |
||||
for i in range(10): |
||||
if i not in [1,2,4,7,8]: |
||||
dic[i].add(l) |
||||
elif counts[l] == 6: |
||||
for i in range(10): |
||||
if i not in [1,2,3,4,7,8]: |
||||
dic[i].add(l) |
||||
elif counts[l] == 4: |
||||
for i in range(10): |
||||
if i not in [1,4,7,8,3,5,9]: |
||||
dic[i].add(l) |
||||
elif l in dic[7] and l not in dic[4]: |
||||
for i in range(10): |
||||
if i not in [1,4,7,8]: |
||||
dic[i].add(l) |
||||
elif counts[l] == 8: |
||||
for i in range(10): |
||||
if i not in [1,4,7,8,5,6]: |
||||
dic[i].add(l) |
||||
elif counts[l] == 7 and l in dic[4]: |
||||
for i in range(10): |
||||
if i not in [1,4,7,8,0]: |
||||
dic[i].add(l) |
||||
else: |
||||
for i in range(10): |
||||
if i not in [1,4,7,8,]: |
||||
dic[i].add(l) |
||||
|
||||
for o in range(4): |
||||
for d in dic: |
||||
if set(output[o]) == d: |
||||
index = dic.index(d) |
||||
summa += index*10**(3-o) |
||||
if index in [1,4,7,8]: |
||||
count += 1 |
||||
|
||||
print(count) |
||||
print(summa) |
||||
|
@ -0,0 +1,200 @@ |
||||
fcdeba edcbag decab adcefg acdfb gdcfb acf fabe fa eacfgbd | aefb cfa acf cdabf |
||||
adbec fabeg fgda gafedb fadeb cdebgf cfaebdg fd bdf cgfbae | ebdfga fbd bdagcef dfb |
||||
cagefd fegabc gbde fcagebd bcedf gefcd bec cefbdg dfabc eb | gdeb dgbe defcb ebc |
||||
cegbf acfeb cafde ab abfecd ecagfd edbcga adbf ecfadgb abc | degafc gefbc ab adcef |
||||
bc gdeca bec fcab cegfdb edbgcfa gbefda fedba dceba badecf | fdbeacg dgbaef bec cbe |
||||
caebdg gfc gaceb adcbf bgfac gf eafg dfbegc abfcge ebdcgaf | bcfag bdgface fegcba gdbeca |
||||
fedga fgebdc dfb edcagb edcab afbc fdecba dbaef fb aefbgcd | bf bcade bf cafb |
||||
cb cfgea badcge gdfabce bec fedbg egdafb cgdfbe cdfb cbgef | dbfc gecbfd fbdc ceb |
||||
cbfdag fcbgd afbgced cgfab ebfgad agcbef dfg fecdb dcga gd | gacfedb cbfgd dgf gdfbc |
||||
abgfd dgcbe dfbgce acbged eab ae daebg edac gdbfcae cgbeaf | bcedg eba eab edac |
||||
gea ag cfaeg agcd befagd fcdae adcgfe ecbgafd cdbfea gefbc | bdeafc defacg gae dgcaef |
||||
bfeca adfbce febd beagc cdeafg fgacedb efc dcbagf abcdf fe | agedfc cefba ef fgcbeda |
||||
cbeafd gfabd dabecg cfeg dfc gcadf cgaed efacgdb cf gfcdae | cefg fgdca decagfb ebfadc |
||||
fg edabf gbedf gedbfa ebafcg egbdacf fgad cedgb cdebfa egf | bgdec egdfab gf acfgbe |
||||
cfe bacge ecfabd dcbfega defa cdfba defbcg fe feabc dbfcag | cabge ef fadbc eafd |
||||
ag gadb edacfb gcaefd eafbd dbeafg efcgdba fag egcbf gfbea | agf gbfcdea cbaefd ag |
||||
adegb gbdfe bcdafge gdfbce fcgeab geafbd ga dgfa age ecadb | ag gae gfda eag |
||||
beagdfc faedc caegbf fgeba caefg cg ceg dbgfae aebgcd cfgb | ceg bgefca egc gce |
||||
dcaf cd cdeabf cefab fgbde efbdc bcd eadcgb gebcadf caegbf | eacfgb cd feacb eafdcbg |
||||
begadcf dbf ecdbg aedfc fbae cdfbga dcbaef bf deacfg cfbde | feba eafb bf cdfbe |
||||
fbgced gcedba gbc fgadc gafcdbe cebf egfbd dbafge cdfgb cb | gcb begfd dfbaecg dbgfc |
||||
dbcega beg gb cfdeba gaceb gfeca gdab fcedbg beacd cfagedb | cfbgade bg bg fdgcbe |
||||
abdcgf agebc dacbg fbadce fcaged gd fdcebga cfdab gbdf dag | gd cefgdba dgbf fbdg |
||||
gb ecbadf gbad edfgcb bgf dbcaf afbcg cgfea cdfgbae dcfbag | gb bg bgfceda dafcbe |
||||
gaefd cg adbfce bdfecg fcbdgea cbafe agefc cgf abcegf gabc | gcf acedfb febgca cafbdeg |
||||
deacgfb bfeacg ebgcdf dc cfadgb abegd gbcfe bcgde gdc dfec | gcd begad befcg dgc |
||||
cdge dfebga gcbef abdcfe ec gebcdf cbe cedabfg fgdeb bfgca | ebgdfca ce fedbgca fdaecb |
||||
bfde aeb aebfcgd gabdfc dgafb bfage be dfgeab fcega gdaceb | edbgac eab eba gaefc |
||||
dcgae afebcg eabcgdf bg agb febda dcbg eagcdb abged edfcga | egcad cgdb deagb gb |
||||
fdceag dbgca beg cegaf begcfa baef eb abgce adgebfc fbgdec | be eb afeb eb |
||||
beadgc gdcf ebacf acdefg bfgdeca afcge dafgeb gf fga daegc | cdgf fg aecfb cbfea |
||||
gfca gfdcabe ecg gc abecdf fbcea fagceb ebfdg efcbg dabegc | dfgbe gdebf cefbag ecafb |
||||
feadg gbfdea acdefb gaebf cfged ad beagfcd dae ecagbf bagd | ad cgabfe cfdaeb dbga |
||||
bcdge adcfeb cadbge bgdafe dbg gcedf acbg ebacd gb dcgeabf | abcgdef ebgcda bdgec bdcaeg |
||||
cfga gacde fdgea cgefbd fgaedc cbadfge gc edbac gebdfa dgc | gcd cgaf eagfdb eagdf |
||||
bg fdcega bgf dbgfcea gdcfe gbcaef bfged dbcg cdbgfe dfbae | gcbd ecfdg fbgde bfg |
||||
gcdabf bgafe dbe eafbdc ecagfdb bedaf gadebc cdfe fdcab ed | dbfea gabdcef de gbdeca |
||||
bcdaf gacfd deacgf bd gbdc adb aecfb gfcbad fdagbe edgcfab | eagbdf bgcd afbdge dab |
||||
gface cbea cfegad bfa ab fdgbc acbgf ebdfga dbcafge cebfga | eagbdcf dacegbf ab ceab |
||||
eabdf bcgafe gfedbac agcdbe gedcb abecd gcad ac bac cedbfg | deacb cab bdcfge dcfgaeb |
||||
cedgf cbgdef gcafde fdae ebgfac edagc cae ea bdefagc bcdag | defcg gebdcf aec bgdac |
||||
cdbae edf afbegd fgdebc aegfcb aebdgfc febcg dcfg df ecdfb | debagf df fcgd eadfgb |
||||
adc fedcbga ad adgb ecagdb dcebg cgead dfgbec eafgc afcdbe | cda bgda ebdafc egbcfd |
||||
cdfeb eafcdg acfde bdac edb gcfeb eagdbf db afdecb ebacgfd | abcd abcd db gbefc |
||||
cdefa bf dcbag cdabf bcefgda ebcadg debfga afb bfcg cgabdf | bf gcabd bdagfec gfcb |
||||
ecb eabgdc cgaeb bcagfd gfedcb beacdgf aedc ec beafg dgacb | gcdfba fgcbead ce ce |
||||
fcebg gcfdeb bdgaec bfdg facged cbg egdcf facbe bg badfgce | fdgb bfcge fgbd egbcfd |
||||
ebfcg bd adgfce acgbdef fegdb fbd gdba gbeafd fbacde agfde | cfbge db gdacfbe abfgde |
||||
bgefc gcde afgcbe dgcfeb eadcgbf dg fbdeg gafcdb bdg fbade | dcgabf bcfdga egcd gd |
||||
fbgadc gcb fcbagde bgaef bc cbdf fcgade cagbf bgaced gfacd | bcg dcebga cdgfa bcdf |
||||
cgebaf egdac aefbdc cbafg becag bfge eb adbfegc ebc bdagcf | be bec egdca cabdgf |
||||
fgd afgdce dg dage decgfb fcdag bcafgde gfcae egcafb fabcd | fcbdaeg gfcdbe agde fgd |
||||
cbfga abg dgbfea dbafegc fceagb ba cfgea bcea gbdfc fgdeca | bcea bafdceg egafc cbdgf |
||||
ebgcda acfegb gbdc befdcag fceadg afdbe cegad ebdga ebg bg | dfebgac dfeab gb gb |
||||
bacdf cgdfae abc ecdaf agefcb ebdc dfbag cb cgfbdae daefcb | bc gcdafeb bca gcfeda |
||||
fegabd egbfa gfa debag decfagb becfa cgadbf defg fg bgdeca | gfde agdcfb bgdcaf bafeg |
||||
gf cbeafgd gedbaf cbfdeg egcfb cfbae gef cfgd egdcb gbdeca | gf fg gef dagcbe |
||||
bac agcbd ba edcga gdfbce abfd egfbca fbgcd bacgdf becadgf | cfbeagd bdfa adbcg badf |
||||
gd cdgeb aecfgb egcabd dcbagf ceagb ebcfd adge dgb gfbdcea | ebfdc deag ebfcga fabcgd |
||||
dcbae agec dacebfg ebdag beacgd afcbd ced decfbg ec dfgeba | gdebcaf dbaegf ce aceg |
||||
dagefb fbecgda adgec afcgde gacf bcdef fa efa cfead geadbc | dfebc bafcdge efa aef |
||||
gbdae cgad bfcde ac dceabg bdgefa bfcaedg cab debca acgefb | ebacdgf abcgedf cab cefdgab |
||||
dbegf adegbc gefdba acbgfd ebfcg gfbad deb edfa ed agedbfc | bfdgcae debgaf bdcgeaf gebcf |
||||
fcgeb dagebc acfeg aecdfbg gedbaf bcgefd dfbeg bc bfcd cgb | cb efbgd cbg bc |
||||
dba gcdbfe egabdc aedbfc fbced bgacf cfbdeag ad faed cbafd | cbfad ad ad cbfga |
||||
edbcag ea ade cfbed fcdag gdaefc eafg faecd fdceagb gfbdca | bgadcef ae eafg ea |
||||
eafbd gfbeda bc dacb fcbega bedcf debfacg edgfc cebafd ceb | dgbecaf gcedf bdca cgabfe |
||||
bacegf deca gefbad adebcg gbcae gbacedf dgcbe ed cgdbf edb | bde ebd efadbg ceda |
||||
dca acdfe bfegac fbeadcg deab dcgfe da acdbgf fbeca edcabf | deacbf dca cdbfage dac |
||||
febg ecfdab abe deagf efgdba gcabd fdegca eb egfacbd dgaeb | cfedga abcefd efagdc bea |
||||
fed feadc ef aecbdf gadbce cgdaf gdcaefb dbgefa bfce debca | dafec cdaeb fbec ef |
||||
fecbdg cefdb gcbe cabdfe cdbgf gb cebafgd agfdc dbg dafgeb | ecbg cgfad cgdaf agdfc |
||||
feacg cgfeda fbcagd fcbge cfa baegdc acegd gfadebc eafd fa | begfc fa afc dbagcf |
||||
afgcbe cfg cf cfde cgfbd gbdfeca gbedac debgc egcfbd gfdab | cf cgfebd cfg fbegcad |
||||
adecfgb bgdcea cbegaf efcbad ebg ge bdeac bcdeg fbcdg dega | dbcgf agde bfcega bge |
||||
cg cbag dcg gdcfae dbfgcea dagefb cgabfd fbgda dgbcf fecbd | gdafeb dgc gc dgfabce |
||||
cdfea dfbcg ga gac eafg adefcg acfdbeg gadfc cfedba edgbac | eafg cag bfgcd cdbgf |
||||
dbaefcg cfdea eadgf dcba cfbaed befcd ace ca abgecf cfdebg | gbdface cegfdb edagf ecdbf |
||||
dcf fcagd gcbf edbgcfa cf baegfd ecgad fedabc gfadb dcagfb | bgfc acgde cf fgbacd |
||||
bg fedgc bfcega dbaegc gfacebd decbg gdba bcafed bedca cbg | dcefg bg bg bg |
||||
geadcf ecfbd bagedc afcdb gcfde cefgdba bce begf be fdcebg | fgeb fegb cgedf ebc |
||||
gbdcaf acgfed gc dafcb cag fbgea cbfga cbfdea bgdc dcfegab | bcgd aedgfc gfeba cg |
||||
efdga afe ea gacbdf gbafd ageb dfaceb aedbfg dgfec bagfcde | fegdc dagfe ea egba |
||||
bfg gf edabg fecbag abfgdec gacf acbfe bdecfg facbde fbega | fgaebc befcda fg abfge |
||||
fceadg beacf cgbdae bgfd cedbf ecfdbag fgdceb edf bdecg df | cfabedg fed dfe gdbf |
||||
fdeac dgfaeb dgfb gfadceb ceabdg gcebaf bf baf daefb aegdb | bdfg gdeab dbgacfe acfed |
||||
ge cbfeda eag fagde fedab ceagdbf fbge ebcagd dcfga dagefb | cdfga ebfcda cadgbfe dfcag |
||||
egcbadf ce afdgc cdefa abedf ecfdab efc bdegfa begafc ecbd | bcafde ecf ce ecf |
||||
ebc gdacbfe gcefdb abefd dgec ec fbgdc fcadgb fdceb gfaceb | cged fadbceg ce bec |
||||
ace egbdac acdef cafbgd efgdc cfabd ea feab bdaefc ebdfgac | adebcg cfbad ea dcfaebg |
||||
fc bagcfed fdabg acefgb bcf bcgead egbca dfgceb fabgc acef | cfb beadgc begca fc |
||||
cdefa agfecd fbcaed bgdeac gaefc ag eag cgbfe gafd cgbadef | gadf age ag gecbf |
||||
dfgcea dgac egabdfc cfdbae edcgf fegbd cge cegbaf cg adfce | cbdaef gec cfedg cagd |
||||
gcdfb dcbfa bcfgae gdbfe gfabed bafcdge cg cbg decg bfcgde | cg dabegf gc gecd |
||||
bf dcefb fbe edagfb gefcd ebcad cbaf dcfeba ecagbd edbgcfa | bfeadc baefdg efdgc cfab |
||||
debga ebgafd gcdafb cd cgd decabg ceagd egbfdca bcde aefgc | cd acbdgf ebcd cbde |
||||
dfbaegc fgcae bgcead gfaedb cdefgb adfge fd degab def fbda | fcdgbe gbcaed dcegab febcdg |
||||
gde gabcde afcbeg dg ebdaf degbfca cfgd bdegcf fgceb fdgbe | fgedbc dbagec gde eadbfgc |
||||
aebdcgf bd ebdag agceb fegad gdeafb gdb fbed cgbfda cgefda | db fbaecdg eadbg befd |
||||
cebdf bgecda efbdacg af aecfgd adf aegdbf abdef ebadg gfab | bdegaf gafb fbegad abdecgf |
||||
adcb daf afdgce fgdbca gfbdc da bfadg dfebgc gbafe fdacbge | febga dfa dcafeg gafcdb |
||||
bgacf dabg ebadcfg bfgdca ceadbf fecgd db dcb egfcab gfcdb | cabegf cdb cdfge cbd |
||||
bg bedfc bedafc cebdfg fedgcba beg gdbcae adefg dgfbe gcbf | edbcaf fgbc egb cgbf |
||||
abegd ecfbga cadfbg gbdecf adbgcfe ac gabec faec ebfcg abc | ceaf dgbecf bdgcfa efca |
||||
degba begdaf gbdcea ecgd gceadfb bgadfc ecdba bfeca cd dbc | cadgbef gbdea dgec cdge |
||||
ceabgd fcbge cdeba cdf fgecdab fd afcgdb dbcfea dbefc afed | dcebf df fd df |
||||
ebd fgbdc cfbe bgdcef fegad be befdg acbgdef cegdab agcdfb | bed gfedb cefb fgbcd |
||||
deb gbcd ecfbgd cfedga ecbdf db edcgf afbdge cefba eabcgfd | bde bd cfeba gfadce |
||||
afbec bcefd afgec cfaegd fgbace ba deagbf abe bcag dafebcg | cefba fgaedc fbgaed bfced |
||||
fabed cadfbeg ecf afedc gfdac agec facgdb ec cdefga dfgcbe | agbdcef efc dbfeagc agdfc |
||||
gc baedg gaebdc edbfga dabfc dbagc gdec gbc dcfegba cfabeg | agdeb eabdg dbagc gdfabec |
||||
dfegab fgd gadc agfdcb gd cfdbg bcagf edbcf fcgeadb aefcgb | cfabg dgac dg gd |
||||
cagfbde dcbfge bgefd ebdfag af caedb daf eabdf bfgacd egfa | ebcad adegbf dcaeb edgfbac |
||||
fecd gbadf baecdg ebfacg fbedcag ef gdafec egdaf gecda afe | fe fe efdc defcabg |
||||
fgbdac egbca gecfda fgadc gfb befgda bcafg dcbaegf bdfc bf | bf fb egcab caefgd |
||||
fb efcdag gebcd faedg dagfeb cfgadb cfgbdae bfae fdb degbf | gbdef afbe gecbfad adgef |
||||
gdcf abegdcf dg dga cdefba bgcae afegdb deafc eafcdg dcega | cegab eacbg dga gedac |
||||
caegfb gfcad ebcdfg cbdfega gdcbf bf cbf edgcb bdfe gedacb | dgcaf gcdfb bfed edbcafg |
||||
bdcfe fgdbaec ecgafd befgad eafbd adf gabd fbgae ad gfcaeb | bgda ad ad fcedag |
||||
agecfd bcegfa fbecgad fgcad gefdc fcdegb fbgad cga aedc ac | cdfag cegdf gdceaf cdbgfe |
||||
bgd befgd fdbceag db dcgfe cbde dfgcba gafecd dcbgfe gfabe | cdbe egdcbf egfcd dbcegf |
||||
ed gdefc dcegfb fecbg fcdag edg bacedg edbf becafg adecfgb | ed ed gbfcae bgfdce |
||||
fbdagc gabdf ecdabfg caegbd ebgaf cfabde cgfd agd gd dbafc | fbdcae dfcaegb gad gabfe |
||||
fbeacg fbcaged fdaeg fde becfgd agfbe de eabd abedgf acfdg | ed dgebafc agefbd fgdac |
||||
deagf efcad dga dfgeca dcaebf gecd dg faebdgc agefb bdgcaf | dg gbeaf fcbdgea gd |
||||
fb gaedcfb gebda gabdec dagbfe fbdae aecdf fbd gcebdf gbfa | afecbdg bdecga abged bdecgfa |
||||
gb bgedcfa adgefc dbgef deafg eabdgf ecdfb acgbde afgb ebg | gb afgb cefgbda gb |
||||
gb edacfgb cdfegb bgc cgaefd bdga fbeac gacfd fgdacb bacgf | gdacf gdba abdg bfcga |
||||
ce befcag ebdca adgcb aec dgebaf bdefca badfe edcf bfegacd | cbfaed begcfa abegdcf cfde |
||||
ceabdg bceafdg gabfed caef ac aegfb bafcg bfaceg cdbfg cga | ac aedfgb gfecba ca |
||||
gdebf aecf bcgfda fcd gcebda fbcde ecbad gebfdac cfaebd cf | cdf dcbage cf befdg |
||||
fdga df fdbage bdeaf adegb agedcb fbd fbcea dbfgec cfbegad | fd bfdgcea aecgbd agedb |
||||
cbegda agcbfd gbeafdc dacge fgbec bd edfacg bead gdb dgbce | bdg acgde daeb gbafcd |
||||
degcbf fg acgedb cdgbfea adgf bfg eagbd fgbae becfa geadfb | dgaf febag gdeba gdbcea |
||||
fcgaeb aebdg gcadeb cegfdb afdeg ebcfgda dgb cdba bd bcage | agedf eagcb dcgaeb cgfbae |
||||
gbecd abedc fegbcd efgacd fegdab bg bgcdafe geb fdceg gbcf | beg bdgeaf gdfec efgcda |
||||
acbfe cef egfabd afbeg bdfeacg cage gfdcbe ec beagfc facbd | cef fce afebdcg acefb |
||||
da afd gfebdc cadg deafc ecfdg gdafbec fagcde edbafg eabfc | aefbdg ad fcdge dgbfce |
||||
ecgdaf df dbeac fbegc cdf bfedc bacgde dfaecb dbfa bfgdace | defcag bcfed fedcb begcf |
||||
ceafbd ecfgbad afgdbe gbdac fcgbed ebg eg gfae egadb baedf | ge eg gafedb bge |
||||
bf abcdfe afb acdbf fdaebg cdgabe cbfe cdbea dgaefcb gfcad | cagedbf acefdbg febadgc edbac |
||||
aegcdf abgecf abefdgc daefg agbfd eacgd cgeadb decf fe gfe | fe gcafedb fe bdcgea |
||||
be cgfdea bfce fbegd bagefdc bge gbfda fedgc ecdabg bdefgc | begdf dgaefbc bge edbcfg |
||||
facebgd fcge caf agbecf dbafg aegcb dcabeg bagfc fc fcadeb | cf caf fc ecafbg |
||||
fbegca bfegad cafe caegb beagf gfcdab ca cdegb bfdegca cag | fgaeb agc ecfa bfaeg |
||||
ab fceadgb bae gceda afbced gfdeb edbafg fdbecg aebgd bfga | ba ebfdca gfedb dagbe |
||||
abdfcg egcf efd efgacdb fe ebacd dbcfeg gbfaed bdcfg cdbef | cadfgb gfce def geabfdc |
||||
beafdc bgdec efgbac gab gdbcaf ebcga gfea ga cagebfd fcabe | gba cbega gaef eabcfdg |
||||
de fdcegb fcebd afegbc efd bdcfa decgbaf gfecb gefdac dbge | gedb edf gbfec ed |
||||
dbfacge eabdg beg adbcg eg abdfe fbadeg adcbef bfecdg gaef | bedfga bdfae dafcbe beg |
||||
acfbg bfgdea eabcf fagbced gcfd cgabfd gf cadbge fbg acgbd | gfdc bcgfeda acbgf dcagb |
||||
cdeba gfdbce cad acbf gedba ecabdgf cfadeb egadfc ca cdbef | defbgc cdbef caedb acebd |
||||
edfabg ab cfegdb adgcebf eacb dcafb ebdcf efbdac adfgc abd | efbdag abec cfbad ab |
||||
abgdcf fdg fg edfabc dabfegc gfac bdcaf egdcb gcbfd fdaebg | dfbgeca fg bfdgac cgdefab |
||||
gcdafb ce cbde fecgd acgebdf gcbfd aefdg gbfdce gcfeab cef | bced dacgfb dbgecfa decb |
||||
gaecfdb cge dacef cg bgead gcead fbecag cbeafd dfgc fdaegc | dfcg gc agced dfcg |
||||
eb cegfab gdbe ecagfd dafcb decagbf fbe abefd gfead eafdgb | gbafed fgeda abfde be |
||||
gebadf ebfdg bgefdc bdea bafcedg feagc adbfcg befag ba bga | gacebfd geadfb acfgbd bade |
||||
becda dgaeb dg dcefab gbd cgfdba cabged gfabe egdc gafedbc | gabef dgb fcdabg dceg |
||||
aebf bfc bfecg bf febcgad egbafc fgedc eacgbd dafbcg ebacg | aefb gfbaec bf fb |
||||
cdgaeb bdacefg afecgd edaf cagfe ae gbcfa cae bgcfde fgecd | cfdage abdgfce defa cagfb |
||||
bedag gdcbea gfebdca adg dgfbac dg faegcb eafdb egdc acegb | dg efgadcb gdce bcegad |
||||
dacfgbe fg fbace fbgae gef cefbad debga gefbcd ebcgfa gfca | cafg decbfg efg gf |
||||
deca cbaefd fdgebca fca bfdga gbdcfe ac fcbeag dcfeb badcf | adcfb dfcbgae gecbaf eabcdf |
||||
gdabefc ca gbefda aec cafg ebafc gcdeba gefba ecbdf feabcg | cfga fgaebd dcbgae bfage |
||||
ecd fagedc dcaegb efgd febdcga fcade efcgab fgcea afdbc de | gbceda de gefbca efdg |
||||
afgcb ecbdgfa bdgecf ad dgea cadfg afd afecbd cedagf fecgd | beafdc afd geda adgfec |
||||
gbdcfe cdeab fd fecda adcgebf adebgc badf egcaf dfc fbdeac | cgafe fbdeca beagfcd caebfgd |
||||
abgfc gfedabc cb dcefga bdca fcb egbcfd dbgafc dafcg gabfe | acefgd bcf dbgfac acgdf |
||||
facge ecadgb fecdba dfcg fc fac eagfcd bgecfda afgeb eacdg | cdfg caefg fc bdeafcg |
||||
efdgb cebadg ceafbg fadcbg bcafdge fag af efgba cabeg faec | abgce ceaf gaf gbdeac |
||||
cafegb gcadfb begfacd bfad db dbgfc dbc cgfde bgcdea cbfga | gbfadc edabcg agfbec dbfa |
||||
facb acbefdg baedfg fbegca gfeadc bae dgcbe geacf ab gcaeb | ba eba baegdfc ba |
||||
edfgba gbfed dfc afdcebg cd cbdef fbaec gedcbf gcdb dgefca | gfbade cbdg dfc cbgd |
||||
bfc fgcbda dgfecb dbegac gcaf afcbd dcbfeag dagbc adbef fc | afcg afgc fcb gbedfc |
||||
dfagb edagbfc dceb agebcf bc gaedfc fbc cfbaed fcdba adecf | bc cb ecdfba bdec |
||||
gc cgdfbe agcb bfgdcea egacfb gefdba dcfea fcg fgeac aebgf | fbgdec cbafge gbac befga |
||||
fgdac agfbed ec bcegfd eadgbc gdcae gdaeb abec ceg bcdgfae | fgcad dagce adfcg ec |
||||
gfcad aecbgdf feacgd ceda fgdae fca ac bagedf acfegb cfbdg | acf afc fac ac |
||||
agcdeb ga aebdgf bedfgc age feadg cadfe egdbfca efgdb gfba | edbgac fdeca acedbg cgbdfe |
||||
gfdc acebf dce adgcbe egcdaf aedgfbc gfdae afgbed aedcf cd | gadcef dc fdecag aegfdb |
||||
agcdeb gdfc gebdc bcaegf cf dabef cfdegb ecbfd aecfdbg fbc | fbc debfc gecabfd gedcb |
||||
aebfc aecgf cb daegcf dbaecg cbdgafe adfeb bce bfgc bgcaef | ceb fbgc cbgf bdcefag |
||||
egfdab cefbgad cbfdea gdea egbdf bed de gbefc gbfad gbfacd | eacdgbf agbfdc dgcaefb de |
||||
adbfce be afcebgd fadbc bed dfaeb badcfg acdebg eafdg cbfe | edb cbfe fdgeacb deb |
||||
bad feab cfdga fcgdbe dcfbe gedacb cadbf becfagd dbeafc ab | efcbgda aebf bdcgafe abef |
||||
dbfeg dfbecag dace cfdbag gcabd cegdb egafcb ec ceb debcga | bce ce adbecgf abgcd |
||||
cabdgf dea abcgd abfdeg acdbge befdgac edacg fegdc abce ea | edacg gedcf dceag bagdfc |
||||
aceg ac bacgfd ceabf fcaegb edbgfc dbfea bgecdaf ebgfc acf | agce ac ecbfa agfbecd |
||||
bgcfda egc dbefcag befdg ec aedc cadfeg cgdaf gefcd fcageb | cebdagf dace ecfdag bcdaegf |
||||
bfdgc gbe acgef gbcade be egfcb afbe bacfeg dfbgeac gcfaed | abfe gfcbd fbgeac dcgbf |
||||
efcbd adegbcf agefdb cdabf bedgca abgdf dgabfc ac fcga bac | ac abc debgac fbdgac |
||||
ebgacd fd bdface cabdf dfa gfcab gbeafdc ecfd ecbda egfdba | fd df dcef fd |
||||
cbadge geb cfdge bg bfeca bgecaf edcabf gcbfe afgb efgdabc | fabg gabf gfbec afebc |
||||
fedgabc cbedg fcaegd ecg dcfgb ce bdfgae gaebd cbea ecdbag | efcbagd bfeagcd ce ce |
||||
gebdcf cdbfga fead aedfcgb ad afegbd gdfbe bedag ecagb agd | ad bfcagd ceafdgb fcgadbe |
||||
fdegb egdbfc cegfdab dacfge dge gadbf edcfb edcabf egcb ge | edg bagdcfe egcb ged |
||||
ad cfbeag adb efbad feabc acfd cgdeba fdacgbe dgefb feadbc | fabce cfbega defbca bad |
||||
facbge cfabd bgcafde agdb fab becdf cfaegd dafgc agfcbd ba | cbfda ab cbfdaeg dfagbc |
||||
eg dgaebc dfcgab cdgfe edfcb adcgf cedagf geaf bacdefg gde | dfcbe eagf agdecf ge |
@ -0,0 +1,10 @@ |
||||
be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe |
||||
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc |
||||
fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg |
||||
fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb |
||||
aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea |
||||
fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb |
||||
dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe |
||||
bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef |
||||
egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb |
||||
gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce |
@ -0,0 +1,21 @@ |
||||
lines = [ [int(j) for j in list(i)] for i in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
summa = 0 |
||||
lowList = [] |
||||
for x in range(len(lines)): |
||||
for y in range(len(lines[x])): |
||||
v = lines[x][y] |
||||
l = 9 if x == 0 else lines[x-1][y] |
||||
r = 9 if x == len(lines)-1 else lines[x+1][y] |
||||
u = 9 if y == 0 else lines[x][y-1] |
||||
d = 9 if y == len(lines[x])-1 else lines[x][y+1] |
||||
if v < l and v < r and v < u and v < d: |
||||
summa += 1 + v |
||||
lowList.append((x,y)) |
||||
|
||||
for p in lowList: |
||||
size = 0 |
||||
|
||||
|
||||
print(summa) |
||||
print(lowList) |
@ -0,0 +1,100 @@ |
||||
4567894301299921298789654345689439843295436789543298765432345678986789756901239998765634567895986555 |
||||
3458963212989890989678943234678998764989945678932198764321456799215678949892398999854525658934895434 |
||||
2348954329876799876567899195789469999767896989949019965432567897434569998789987898743212345695679423 |
||||
1237895498765698765479998989890359878956789999898929876545678996545698987678976987654563456789798912 |
||||
3456797987854569954398987678921298766545678998777899987766789987656987676569895498765676567899987893 |
||||
4567989896543498765987876567892987655434567897656798799897894598767899565458789329876787678999876789 |
||||
5679878789432579879876743458989876542123456996545987678998923459878998433347678910987898789998865678 |
||||
8798765678921456989865432365678987678012345989439878569899012398989987321234567899998949898987654568 |
||||
9987654688932368998765421234567898632125499878998767476789323987399876510126789998769434967896543456 |
||||
2398543567893458999876510195978976543236989656989654345895439876210965432345678989754323456987432345 |
||||
1987652356954567899985431989899987654549878949878943234976545985431986583556899679943212569898541234 |
||||
0198621237899778999996569878789698765698765436567890125987689987642398874567976567894323498789210123 |
||||
9239432348998989998987698765679549878789876323456789239898992398543498765678965456789434999654321234 |
||||
8998543459987899987898798754678932989899985434567894398789943987659569898789654329899949898765432345 |
||||
7987674569876789876789987643767891296929876765678965987656894998998979979898763210169898769896543456 |
||||
6599795678965699965679876321458942965439987878989879898545899899987898965919874323456789656987654578 |
||||
5459898789654569874589765432349899876598998989894998765434789789876567894301986545678998734598787689 |
||||
4345979896543498763459896565456789987987989998763219896545697698765456965212397696989654321239898793 |
||||
3254567965432987654567987886767891299876767899854323987676789569876345894343498989898975434345999892 |
||||
0123979879521098975678998997878910198965656789967456798789893498985256799454569978797896545656789991 |
||||
1239899998632129996789989798989992987654547899996567899893912987654345678965698765686789656767899989 |
||||
4398789876543234989899976659999989998743234598989699989932102398965457789898789654345898787878999878 |
||||
6987654997654399878999865545898678999654123987678989876545293459878968898769899983236789898989998767 |
||||
9876563498969989769899854236789567898763234976567878989676989598989879997656999874345899949899989756 |
||||
9765432349898876658789743145678978999854569865453569998789878987899989789743298765456789234789876545 |
||||
9897561298767435345697653234567899989967698774312478999898767856789997678932109876567892125678987634 |
||||
8999990129854321234589754745678999879878987685101387899997656345678954567893212987678943034599299846 |
||||
7898889298743210125678965678989998767989999543215456999898743237567893478954563499789956745989398767 |
||||
6787678987654321367889876989999887656799898654323567898765432123456789589765679599899877659878989878 |
||||
5674569898765432456789987898998786545698798765434678979878741012367998678978798989924989798767878989 |
||||
4323498789878543567897698967899654323987679878555789567997652323458998789989987678912398987856567899 |
||||
3212347678989697689976569458789765219886587989676894456989543456767899893499876567893987996543456789 |
||||
2101234567898798797895435365698954398775456898789932349879656567878954901298775456789896789612345678 |
||||
3232345678979899896789423234567965699674345679894321298968987678989543212987654345698765678923458989 |
||||
4563656789765932945678910123679899986545234569965432987857899799898954329898765257789674567934567897 |
||||
5674767899854321234789543234598798997632123678996949876546978998767899998789954348998543456895688976 |
||||
6789898998765430123897654345987687889875012399989899985434569987658998875657895767987432388996789765 |
||||
7895919987654321234998765499876576778964323989878789876323568998899987764546789879876321276989899876 |
||||
8954323498765434345699878987655485567895439876567678987212567899999876543534995989865410125678999987 |
||||
9765434679876595456789989987643213458996545985434569874323456789998765432323894399986423234789998998 |
||||
7976765789987876567994399876543201246789759886323498765434569899879894321012789459876534345689987989 |
||||
6989876894598987878973234997875212345678998765434999876545679998767987652345678967987649876798765678 |
||||
5492987923679598989862125987654345456789329876565899987786789987656399543458789978998956987899654568 |
||||
6321098912395439799654434598765456567893212987876789699898899876543297654567893989879987898998743489 |
||||
5499999101987325678969547679976787998999543498989896545999932999632198775878932398767898969997632378 |
||||
6987893245896534567898956789987898949698956569193987659899891098949019896989991987654329459876541267 |
||||
9876789356789645678987897996598989434567897692012798998789789987898923987899989998763212345998765459 |
||||
8765678969898756789256789543459876323456789789125679989678679876767994598999878989854301456789876567 |
||||
5874789998979867894345678932398765614347899899434599876534598765656789679998767678965212367899987678 |
||||
4343467897767998965456789321459654301256789998765987988323989854345678999987654589654343479999898789 |
||||
3212989926456999987567895432396543212367899899899876543219876543236799989876543458965494989698769894 |
||||
4343499212347894398878989693987665323456789789989987695499965432125678978985432367896989896569654923 |
||||
5454578901456943219989878989998786734569897679878798986989876743234599769876921456999976789696543219 |
||||
6567689212567899324599967678999897895878944598765659987976987654345678956989890967898765698987654998 |
||||
7678998343456898935679756567899998976989432129654745698965498765458789545698789899987654567898769897 |
||||
8789997654597987899798743456789879987896545098743434899876569896567890124987698768894323458999998786 |
||||
9897898765989876568987654567898765698989652196542123987987678989698921239876567656789214567899989645 |
||||
9956789879876543456798765678989854349678943987663039876498789878999632345985454347898996789979878434 |
||||
9745698998767432345679896789876543234567894598754198765339899867996543459876321238957889895659762123 |
||||
8634567899654321238789997898987654349978965679865299873210998759889654569985432349546778954349843234 |
||||
6525898998765432345893298967898795998899876789876789954321989645678965678996543489435568893234956785 |
||||
5436789129887643458932139456789989876789987895987899977439876434599876789987687678923456789125987996 |
||||
6545679012998786567891012345899876765898998934598999876567965323689987895398798789212345699934598987 |
||||
9876789199129987698972357896789995854567899325679999987679873212347898943219999892103479789895679298 |
||||
3987899988997598789765456789899984323456789212389989898989932101236789992103498943212567998789792149 |
||||
2198979876789459899896987999939876434598994323459878799999876512345699983212987654323456789678989234 |
||||
3239567965679345999989898998929987545989987654598765634789965423457999874323498767654567898567878945 |
||||
4999459854567956789878789987898797659876998765965834323679876567568998765454999878765678997434569896 |
||||
9878398765699897898765679976545698998965789899894321014567987698989549878969891989889789986545789789 |
||||
9765129876986789989874798765434569987654891998789543223478998789794323989998710195999897987696897678 |
||||
8654234989875679876743459983125689998785992989678965354567899895699456799987623234599976798789977567 |
||||
9766545698764568995432369894012378999876789878567896765678932923988998899876544395989897899898765456 |
||||
9878656799853656789321298765623567894987898765456989896789671019977789921987895989878789978987632345 |
||||
9989867987942345693210129898794678923498949987345678987896532198866678930298999876765678954596543456 |
||||
9896979876543456789521345999898789213999239876239789498986545987755567891979998765874567893987656567 |
||||
8755699987654567897432567899989892109878998765458991349997679876643456789767987654323456912998767778 |
||||
5444598798767678996543456789876989298767879986767890145989998965432387893458998765534567899889898989 |
||||
9323497679989789987894568998765678987656767897878921239876897896521298932347899876765678965678999496 |
||||
8939986545698993498989979349654349876545856998989432398965986789430989549456910997876889954567894325 |
||||
7898965434577892109879893298743212965432147899996545987654875678949878998967891298989997892349993214 |
||||
6587894323456943998765789349892109876543236789987659876543534567898767897898932999292356793498989323 |
||||
5456789434567899899854578998765412987656745893299767985452123679987656786789999899101236789987879434 |
||||
4345678946678998789943469549894329898767856794999879876321014989699542345999987678912345699996768965 |
||||
3235789987889997678912568932985498769878967989899989965432127894598431259899976567893456789865657896 |
||||
2124899998999876589893467899876987654989879876789999876543236893987640198788893478999567998754346789 |
||||
4235998989998765498794878945987896543296999765678998987664345992987651987677789567898979899893235678 |
||||
5345987878999654346689989234598987654345989654567897898785456789298769876545678978957898789762124568 |
||||
5459876567898953234579890123499998785459876543678965439976567892129898987634389899545987689654335679 |
||||
6798765456587892145656789294989899896567985432349876521989878921019987896521256789434596578965445799 |
||||
7999874343456921012345999989876789987679876545678965439997989532198756965432345694323987459878556789 |
||||
9899983212457892123456789876765695498789987658789997698976596545349867896545696789109876367989769899 |
||||
9789874343468943234567899985634789219898998969899989987897697655459878987856789895414995499999878998 |
||||
8676965656578998745678999894323478901987899878999879876789798798767989498979899954323986989899989987 |
||||
6565698767889109656789698765434567899876789989898765765678999899878995349989998765456899876789899886 |
||||
5454569878999998767895549898745679978987897696789654344567899945989965210995439876787898965678789765 |
||||
4323456989769899878934135987656789567898976545698743213456789434597894329874321987898987654565678954 |
||||
5434567893656789989321014598967993456799895434997654302345678923456789459765210298959996543534567893 |
||||
6547978932345678995432323459978942367898754329876543212456789014567896598654354349543985432123489932 |
||||
7656889321256789876543434567899431234789843212987655433469894323478987698765565458932976543234567891 |
||||
8798995432367899989656657678976532345678932101298766545678965435689998799876676567891098764546678910 |
@ -0,0 +1,5 @@ |
||||
2199943210 |
||||
3987894921 |
||||
9856789892 |
||||
8767896789 |
||||
9899965678 |
Loading…
Reference in new issue