first commit
This commit is contained in:
53
2025/day01/secret_day1.py
Normal file
53
2025/day01/secret_day1.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# import math
|
||||
|
||||
# with open("input.txt", "r") as file:
|
||||
# input = file.read().splitlines()
|
||||
|
||||
|
||||
# count_0 = 0
|
||||
# count_100 = 0
|
||||
# start = 50
|
||||
# step = 100
|
||||
# # input = [
|
||||
# # "R50",
|
||||
# # "R5",
|
||||
# # "L200",
|
||||
# # "R95",
|
||||
# # ]
|
||||
# # input = [
|
||||
# # "L68",
|
||||
# # "L30",
|
||||
# # "R48",
|
||||
# # "L5",
|
||||
# # "R60",
|
||||
# # "L55",
|
||||
# # "L1",
|
||||
# # "L99",
|
||||
# # "R14",
|
||||
# # "L82",
|
||||
# # ]
|
||||
# last_value = start
|
||||
# count_diff = 0
|
||||
# for row in input:
|
||||
# dig = int(math.fmod(int(row[1:]), step))
|
||||
# count_100 += int(math.floor(int(row[1:]) / step))
|
||||
# start += -dig if "L" in row else dig
|
||||
# start_new_temp = int(math.fmod((step + start if start < 0 else start), step))
|
||||
# if start_new_temp < 0:
|
||||
# start_new = 100 + start_new_temp
|
||||
# else:
|
||||
# start_new = start_new_temp
|
||||
# count_0 += int(start_new == 0)
|
||||
# if "L" in row and last_value + -dig < 0 and last_value != 0:
|
||||
# count_diff += 1
|
||||
# elif "R" in row and last_value + dig > step:
|
||||
# count_diff += 1
|
||||
# print(f"row: {row:<4}, dig: {dig:<4}, last_value: {last_value:<5}, start: {start:<4}, start_new: {start_new:<3}, count_diff: {count_diff}")
|
||||
# last_value = (start_new)
|
||||
# # print("="*100)
|
||||
# print(f"count_0 = {count_0}, count_100 = {count_100}, count_diff = {count_diff}, Сумма: {count_0 + count_100 + count_diff}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
19
2025/day02/secret_day2.py
Normal file
19
2025/day02/secret_day2.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# input = "11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124"
|
||||
input = "5959566378-5959623425,946263-1041590,7777713106-7777870316,35289387-35394603,400-605,9398763-9592164,74280544-74442206,85684682-85865536,90493-179243,202820-342465,872920-935940,76905692-76973065,822774704-822842541,642605-677786,3759067960-3759239836,1284-3164,755464-833196,52-128,3-14,30481-55388,844722790-844967944,83826709-83860070,9595933151-9595993435,4216-9667,529939-579900,1077949-1151438,394508-486310,794-1154,10159-17642,5471119-5683923,16-36,17797-29079,187-382"
|
||||
|
||||
result = []
|
||||
for row in input.split(','):
|
||||
if row != "":
|
||||
temp = row.split("-")
|
||||
for i in range(int(temp[0]), int(temp[1])+1):
|
||||
word = str(i)
|
||||
step = 1
|
||||
while step != int(len(str(word)) / 2) + 1:
|
||||
chunks = [word[i:i+step] for i in range(0, len(word), step)]
|
||||
if len(set(chunks)) <= 1:
|
||||
result.append(i)
|
||||
print(f"step: {step:<7} i: {i:<10} result: {result}")
|
||||
|
||||
step += 1
|
||||
result = sum(set(result))
|
||||
print(result)
|
||||
200
2025/day03/input.txt
Normal file
200
2025/day03/input.txt
Normal file
@@ -0,0 +1,200 @@
|
||||
3233434223352253322244323562413222322422522622312422332123223123235422212196323222332232332242222211
|
||||
3253614853357641354235554359223421643245222233522454235444233724594363132335424368397242223752247462
|
||||
9227239868322117352232362225792331173225245472224691494523554293342322397272234344174282584212632643
|
||||
2424427442225542232141143324314232343124223424241231211342242622362444432233422264224212412122323332
|
||||
3536356555555254554458745555556554543654364545233353445556426485625644556442344245573445655546547445
|
||||
2125221522224632224228122521233229122322592222122222221222132516324622212421252262622222352132722234
|
||||
6252545344542548453533442455575334459433855258434364358454454543454344246255949444437618353445534344
|
||||
4292255132464529313583131252362444533443435843394228724663225212343243463374432472435632124842352434
|
||||
2762222592352924222275262242222222452412122221122271512225212411622522225322221222122222322133222222
|
||||
4852223544447635443434243624333542242224241372825413573351446345743522443344645332236263263762624344
|
||||
4349274612743732212485534653333578552372739579576444157766243426563697474333496632366293598633535373
|
||||
4375445256312456536533554464463531525139655364653462755665547336555453565252335468555424452555554645
|
||||
2422224232262712327643315322415212622227112325322215532322441425232827124122442271412323132121293265
|
||||
2323133334132513333243331232333323233333333233222313333212333333323223434223333333432323433253345335
|
||||
2433423433231222225322352424122346254251152632232384122225231122223242331162352222334363243343122324
|
||||
3434355225555555566224624455223344564222445534566524443551354452554855555453544555344545534554345555
|
||||
4565276262256667756426234376614837776135256372624453556677672437746676938557862642475736753493577446
|
||||
3262412844241214224631445232671625224232382444514525144222322222222342212245222656423344231445641222
|
||||
5433333333655265464423322355226325364733264245332366247345235341123632263235333423353335555123254543
|
||||
1397225572534321823411246135242626424761428548562516836659373723657222362489418634223472666642792414
|
||||
1465553556355435456445554454545655545655578565453374755538545245643457535444454434436247446457537557
|
||||
3733833134435556133536354344362263333332737231143564432337534433233544333236335442243581532532357314
|
||||
2223222241122142132381244521921222122348423214322234133472252462243132761622213223223122232212223323
|
||||
2222233222222217651224263621121922252533112222522166322525222432222772221272285152171252623852212752
|
||||
7333324432333412833348434444734223354447223331164743332473323225233211435343463423446334247333344243
|
||||
3512322255221422131231232722332232131558242222172514425424312231311413522232422243222243212243242324
|
||||
1222332222322322312332221322112212162232223232132222222223221222223232122213221113223213222222222232
|
||||
5223344123222224532132233342732466522424622922622523327352225522125354522245221424515232225324258724
|
||||
3345322232725333524234315233553821333334311316232323433334334332336612133333734123322212333331434334
|
||||
4321225341122244351222324223222225152322222222222222222122224222222252235212112421522224341252312342
|
||||
3222222231232322221133222122222222322232222121212232322112212212231232222222222222212122211121322222
|
||||
7322222252415231233421333222232432235324235352164354243131443233312221332227322525422233122323212121
|
||||
2355474641533245251352455545542325533454455522355344444555534343453843135555442355145455453555532235
|
||||
1632265256245226275566213677372352523545347777564711679226525245656615741389232776562768786126766335
|
||||
8852393666733678552782367326698565648872863674638822424768679678752822857668756368541245472463784974
|
||||
3822212122332211223323221342143922122222273245214231212212222221221231222241242342222622122222722121
|
||||
6364436446747742555153534464674455557448568627544647375556276567674745443663778366674735764563737565
|
||||
2243343143333333534442433234453353225352434263233634544313333343123243423333445292323513223123311433
|
||||
4333212443563553243565234351252474534232456533433333337456313322523322432363233345532252245534421121
|
||||
3252332333423343312223542723333335322424332432531243252232333333234333353352223311335222232332232532
|
||||
5533439245354533447342385334432374434232525555454344355453333353443345355544455435245354625335545445
|
||||
3333325864261655356754533666353323233145152593623333533343372623435262345533346259533364538633378333
|
||||
3473346242233533323363421434232734532221331343422234236474234443443333123323423391532343225434272232
|
||||
7366222421652335466351623246356642723763254423466525432345435553473257562555757666354414354665489432
|
||||
3723331332223422133311343123222531322222331323632335233133233323432245433222222323342323242332424225
|
||||
5553435536324441466455643556353456414344365454277343525742721344157345254364432664473565223722443534
|
||||
8537355563535777467446572263844759259616336922663955557767416745673468484863385347357356415459664565
|
||||
2221222322122222162133322132122212221222222222222212244223222212122612222122221722221212331222131123
|
||||
3236412322432437444432134334322123342231432433231333242433322324332324344532243353454441343334321413
|
||||
3245434435444524522453324343434345444334436544324443244432334553744334545333643444444434432544333213
|
||||
5222723553534423124222241222323333232322232412322221323643224334214121322333333443322322243545233322
|
||||
4362232222134314244127243531242322222431234534252221224356262242352236454242244235126244322124562536
|
||||
8433422646454234357562347352664333212228454745121634243134353136333222342543344286835245524342424224
|
||||
2322134211222222322226222221214114242222422212322242413211312122554224222122214521122212132223342211
|
||||
4134222326442311415331442834442474317134471242336451414513244442324322337242343322424622423162269562
|
||||
6222422121112224223222223221322211222212222122222222222222124221291422222724321222122615222221233247
|
||||
5424457225531527744642563453673622445422339553321245413753456375453352333569361487554254133435764434
|
||||
2223232312223222222212121224122212222222222222222131212112212112252222222223422125122221211244222522
|
||||
3732751544412323223224391973324424272324347453443333223246334233223512212342346222234249445252943235
|
||||
5347744439564453327367844455546534253934545593354694537538564363845976255724545744498874535656542546
|
||||
3254323235223221422425324234332221315232223223342132452311945263222523222435223323323522245233123353
|
||||
3743353634233352453346435735343393375445333324343345634435343435445653352354593553535544484345344354
|
||||
2322237632343222228222212422222322461322332242223222362252421633323224121422222232322732161237223243
|
||||
7438576248685545162156286783342851767862361385715781816284251827733255777811257845172412423311162519
|
||||
5115312553521425414562546225232532356244216654446513522221653612551562461252456512141523465311661789
|
||||
2325221133442222142231322232215124413315342431732234342344322222232222232249344124222273244342541222
|
||||
3323333334233342423322333443132323324231322232333223322133333233322321122332333373224322223231332332
|
||||
3253333422242331322523333433223433433323243233221324243333322332233143543332333334313243232122313532
|
||||
4341633542526521434336453424422342232132235235423234532325332523544432345255333254532332242222444552
|
||||
2255224343322253435554225344432542336342545422113332427313332253252434365233453223153384424242343333
|
||||
2411251326182244235132436731443225242261222232642251466222524222323243134313322223144221241222335556
|
||||
3122372267235524211233422363142329222412225723222333392123225623322332324223333152253423942327126222
|
||||
2224251322432221121312223212132339242222222212422322212422221324331421312231232241222323224263236324
|
||||
4143332633242423437232431434343334453353423244224132333144243425632334444413434542444341444424444343
|
||||
8722243312132211421312244251422242223739324117224225644314243225376541733242222254725323224244442152
|
||||
5518669262833439462463231443422923454144256515864667516723998581124225244657655744648546653234418758
|
||||
2252113232252122223223521232352222223824212433411222524522346221223142122242443322224333223221223222
|
||||
5455326542353257656646614685667446635675264654474246666644273565484564665445346481665453637443436648
|
||||
5455457542675545444155262245473224346355414676554412523455434245753561546265414341453456433626534225
|
||||
2222222223225452142422241231421241122244222222244222322221221122313142235134322211254232221437142523
|
||||
5633342343328766578343526433334265434933993644526159345143521845254233452973573342454149833533676223
|
||||
2382252232333232233222242253456272222311336232223123371134341255521223335721832753312238222413522352
|
||||
2225225363213251354332122224333233254424223133512323625552454322223244145323342614335334263521252532
|
||||
2231334124334454443124333323133513325434133442244352344544154434243444424333234233214445333443333423
|
||||
3321333423123332312383312833223934333232223333323335622333233333332328324633358234436732323333223333
|
||||
3113313242131112241443442441442131223243322414443411341212242331241322421222122124442314322421256789
|
||||
3454134434525114544125453234415134114433253131333543512252232114133231531332413232524451313525356789
|
||||
1323522532331341332334312313424343312531323312423314233233223343233433233443433243223333333343333333
|
||||
2332232433333333352835331323232323333342323233222333232234323343333224333232221333332333725333352333
|
||||
3667555243538554534723326555646122325422232265353566454255336525645452424154262544865665447451174466
|
||||
3222122222323422322222222122322222222511221213534121224222421225222253225122272322212222212922222123
|
||||
3255563144344674253649428443153223434344254425565553586934535543444374232446653464635632542432543543
|
||||
2153533413224541552754435333232545352523125254225221254247333215232442242244631233244521532432563322
|
||||
6247431423124442364443444342324529433329473434983444227424542242442245444413344423673244364333434443
|
||||
8626248327141522235452322255122141223422142445142272372627558325217122322224233259247534233422432254
|
||||
7444464934454423544944496443744433954643444455344375469439433337354632492438663445643345354434646634
|
||||
6643364665334325635555543564373355543464456554325455556356645445546513463455415766444434414435754654
|
||||
4397429513623422923952372255275512847136269232822224229381272422332243834254332338397455512322229432
|
||||
2922122225222232312272223122422222462232152262552962222233222422264134611129229224342124223233271183
|
||||
5511223342242212431222262212222222232212222113222222222112122212222122312321121221112252213222412122
|
||||
4242414233222222131422633242334222433224133346242242222225442241335222253123232322122425328542413522
|
||||
5344244252223343241414343252431452333342332462222232453326423233614433233424421323334313332232452634
|
||||
3236353142242654133442461252342663331463422323614136552513624523526526634355325173654433322362563336
|
||||
7264122465242333729834428284249225651445175952362255551525425465145162871942731215427452112212251822
|
||||
4334432386432223533343643455322235234713443543415233443243532243536346422443435463243853353332452315
|
||||
3632633333133438233253223432432355142533423353261333534124372254232321233542422233324367643152214236
|
||||
3674334316882423336331231123328434434242442438328441343232742123321352422322344321282452237421224333
|
||||
3353334433444333554112432335343235334323333541424313143455253314353363334333543322423533233523133223
|
||||
2222222213222221222222221322322223222223222421324232264222322212112423213223323223222223122222221222
|
||||
2232233334232223126322133222222222244243233342222142132232243222212213422232233322342212331223342214
|
||||
4745534543334542664345445434543428255453444645574445352454355434474234242553554554546123523333455425
|
||||
6353844868287536773782841458758767397846315373627445746677754956774567764644658926535797986377255924
|
||||
2233332323213343331231722712333233331323244122327333221332324252221433232242244313252214452242122233
|
||||
2423234312323233242232332322234343143124432112222324211444324432233424721734223252122424323364423163
|
||||
3364325333743344353443373233855314533354337733133286433431434324532334342483334324337329214334734464
|
||||
1234335649342455534333335854652476724447343337545234313841523435446243334242523334233543444459542843
|
||||
3764242272775326233322336243223634122632142313523223311223233215444333331223612311513223132532413512
|
||||
2141242332222223213334222222435122232222343132312221133211321356322422322222223232221113332233212232
|
||||
6337884427639742538124855861193965853198845235447434338649447587733646366368382465642997374268728239
|
||||
5246573532553323333324342227313834348432353742453323831424234421225254553238135321353333315445274341
|
||||
4324524442342254524352533444262422333634235444141245436253543253313335225324333421453422242231232345
|
||||
1332324333121463423342423111362346234544232339791383953242343483225232826722263723422468513943325332
|
||||
2313422235212222322222122238222322112112231222221242322223242222122222522231126222221212222222322222
|
||||
2121121214222332222122221432222523226322222221141421222231222222242231222221212224442234121222242222
|
||||
2221232425216122221222727522261227624225234256166255327227512632224216222222262112532231322412432242
|
||||
2214413222222222432313321122212223523222222243232221222533322331222213164222232333322232222222222422
|
||||
3474334352152453232546257146494454324442232144333444466164653433353347635542557338142155652724415347
|
||||
2225222422222112322227422122422221352122222225212222232222222223162116232222222222262212221221222222
|
||||
3523232321622212233226321224351513636122232327322143161327264525253421524282624661242632232142216432
|
||||
3333133443222353321333342223332542333133423353223553233333232333454323333334332533322323334133332431
|
||||
5432433432444524256526253325535633235455652522335223353556536543346546243224433533254643154223333335
|
||||
3433632345223535323382843433623233263534323334263375526335352313543483244633383233923543472467347393
|
||||
3233343593333363533333425734635632233292371333523335523354364325633233333323333373323323336635525336
|
||||
1321222323423224272222223323222342263322222213231232123212323222222222225222232221252222322162222121
|
||||
2322322222223533226252222221222222232238225224162135322222224522452135222254223226452222234213412522
|
||||
5745895664666384653736445478767577446967469565667276375746154655976665764474643666647664764746567664
|
||||
3247237445355255253345255441484326427454555553525134842412455555353584537548445355523243457525465246
|
||||
2226422212311213332221522412322123222222222212221221222122122152124122242233222222221422214222222252
|
||||
4454556254459563464443544545765325867544564543441377454636564356644654486299547654545894367655354545
|
||||
2142343432423132383324344244311742144847722432343215424244261442245444544833341322432342542134364446
|
||||
6445655254665248466464439415552268326649566422554674756449662965625323856995845245323844582246327684
|
||||
3232333233232223211422332232322212222231223232251222232212123333233212332232222253232232422223223422
|
||||
5224331332221232322222242222212112222322221232233223132133123321122222253233222312223323221232221252
|
||||
2114233536224334232231332322333333333332313314833333343123265252342234335243533233523233133313342313
|
||||
2542577373852542731466775663577644332473742423376424747568725477755642763635762543624226547844461244
|
||||
1241332233432223226233432334213323343143141322333424123532215233623232433322223222323243821233323323
|
||||
5432244423243333432233643324423444234343443441334243343244221432254434433342423424423444454643432421
|
||||
7323255215333443182352353343444323432535344353532422453345622332514243535444333443353234344343424535
|
||||
7676456443423282324444341246429442442624435332422244524244484263453723834377452434423633374241498114
|
||||
3222222414523432231212321322522123243231222172432232121224552422313242411122122225222341324128222222
|
||||
5456466245944734354336553425722324557576564816328284445636697447734584542585343348842545348358495422
|
||||
4774355625888748466596384753478975595734488665375698574534469644586563875455828484667699796694956475
|
||||
4453543565653458345745334745253338755474244456262744255437468454545555555435684457457545574555237697
|
||||
5221448943236541444222452331355412132464312464214534323443332325344338245227234444343564442243224424
|
||||
2225433542853255445622726112271326472237676272622332521242524355155224229767312226266262697522228562
|
||||
4245322237618222749482563542832146722525254225742426232323452845861323232662265422523222225824223344
|
||||
5342144525555442243524226543555252544551444242536724323423225333452343524666542565453245234446336555
|
||||
2222254252222324234415232216222421112224222343531222345221211245524472221532252244222334226211232221
|
||||
4633244444444324422324449343444524242357752823544143644214253223436717448318646382262314413524324164
|
||||
1222221432151221212273222122225222222212222212122221322221222221232322213222126222223212213221222213
|
||||
2223223322322322532323222222233232222331322422362222822132221241123432122224292232722223242244242232
|
||||
5122222232524253313126332513323225211332323437232212353222634232244332622181622522323233333215295251
|
||||
2342334437573363563251634213222833538222333939324363724323278492711423222432132532335255352546382635
|
||||
2322241213333244216912253361234232222135423362224613422214442424255132222224322234363833155232222153
|
||||
3322222131224322522222232334422362344212522153223242222532422223223321127222211222222382226422313273
|
||||
4534443553543233352333333222373323435443464127232335323235338454333334453555335522533832355543568352
|
||||
3335332552559449579743485583354984335667754938846634895727415973388522474359346754553745395999873337
|
||||
3312233322233133342233122332314334133221133342321433224232234313232332314333453423334333332353333332
|
||||
5462554839223255344234422742435245136459842337232365551747632255237755423652346145253745296436153231
|
||||
2544546447646354664453463544636533372447554294444335533646643534444344464456474544436344453343443666
|
||||
2221323233262222221223232222123223222221223222223223261112212222224232222122222222221222221122222213
|
||||
1222211222222122212121312954215624222222242121622222213222222222222132422223222224623222222252211222
|
||||
3523252353455658395544261358443335652773354572335356125642357854221445937756524556635322563733815542
|
||||
2232254421322435224442416742332652623444215342561423425445342235322331431522422453349514332231113223
|
||||
1622332212335233432212232243116322231212322331322423232322222333233322233433222232223222326222432322
|
||||
1323224127234222124222422132334425436632235223724264324425232344412242243242341142242153325224223432
|
||||
5676356343453545645856446543444423424643243454468243335635454346534234343533446433343223324445335425
|
||||
2546335436646364623433766633546584514643633484336622953555565439762544874223843256443144372354365355
|
||||
6322233212112432222223223222122233252233312222656242223233512223226213232122253623213323332321623282
|
||||
2323423324232423423343443424334333244333324432332222344343233133333335224342324822423313343243133352
|
||||
1333343242342324333445333333343533346443442343123333633336733335353336333111334241334143425333253362
|
||||
7543555492363454454494466647645365526445443444346666337341454664466453555349494476645537674747744737
|
||||
3333323233533335333314223333223344334583322331833233223714232435323233536743333323313343244233533313
|
||||
4533434546445547343347424653663453256443332341552393553473435436432335343235553543445523546333333335
|
||||
3352342434333233633432235332523223332332324332353433232323132124322223134326312532423233333233222323
|
||||
3322132332333544434355332232452352223533435334135534353314425442523332333223332332423341123411333624
|
||||
4653642672523233724824222555842742243725715122484274376345616854735434951874343232145427662736537446
|
||||
6173747773236371317437424161244656344672244533235352325341265263552344467273762645221615767426121489
|
||||
3623633522344422725443425223212442385144233212164216833313433312874343444443224333143352331353233324
|
||||
3317343615333234334433333342231323323225154223233434231413333322323125332323334333333443335233434244
|
||||
3522823452247382354324534226133323442224652942753522375833343823263231334353555656535242421272774842
|
||||
7333323352387633232734421223342223722462872352373442333535222333333238435714333532353244753737722533
|
||||
4442543321134443452333446534434734434375643351222643474443425446245434314345323344444514442444226443
|
||||
3285251637222363222472154314252527157326423323532213732223724533233636375713623545544337332247253314
|
||||
2434537364266435723623439434672297422363474496151226335622565553353675522467894763239225733373759523
|
||||
2232323221222221151222312222222212323133232522422322212211251221212224212217223322338342123233123314
|
||||
3342372423233323235633444345333332445223334536342333543333153524353231237143223233424425313331423325
|
||||
5767884946576766546558768767844146766387555466875566737775468663634866855528868858567496986549486867
|
||||
2223243442223221323222443212123122122114332122222421223222212322234142133322222232221222222253121122
|
||||
1122222222222222212122322122212232112223122222222221322212233264122442222172232123321212292322225222
|
||||
34
2025/day03/part1.py
Normal file
34
2025/day03/part1.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# input = """987654321111111
|
||||
# 811111111111119
|
||||
# 234234234234278
|
||||
# 818181911112111
|
||||
# """
|
||||
# input = "5767884946576766546558768767844146766387555466875566737775468663634866855528868858567496986549486867"
|
||||
result = 0
|
||||
|
||||
with open("input.txt", "r") as file:
|
||||
input = file.read()
|
||||
# читаем ввод построчно и возращает block
|
||||
for block in input.splitlines():
|
||||
# проверяем что в строке.
|
||||
for i in range(9, 0, -1):
|
||||
# print("i -",i)
|
||||
if block.count(str(i)) >= 1:
|
||||
if block.find(str(i)) + 1 == len(block):
|
||||
pass
|
||||
else:
|
||||
if block.count(str(i)) >= 2:
|
||||
split = block.rindex(str(i),0,block.rindex(str(i))) +1
|
||||
# print(split)
|
||||
else:
|
||||
split = block.rindex(str(i)) +1
|
||||
ii = block[split:]
|
||||
# print(ii)
|
||||
for y in range(9, 0, -1):
|
||||
# print("y -",y)
|
||||
if ii.count(str(y)) >= 1:
|
||||
print(f"in block {block},bestcombo is {i}{y}")
|
||||
result += int(str(i) + str(y))
|
||||
break
|
||||
break
|
||||
print(f"result - {result}")
|
||||
28
2025/day03/part1_my.py
Normal file
28
2025/day03/part1_my.py
Normal file
@@ -0,0 +1,28 @@
|
||||
input = """
|
||||
987654321111111
|
||||
811111111111119
|
||||
234234234234278
|
||||
818181911112111
|
||||
"""
|
||||
result = 0
|
||||
# читаем ввод построчно и возращает block
|
||||
block = "818181889"
|
||||
# проверяем что в строке.
|
||||
|
||||
max_value = set(block)
|
||||
# max_index = block.find(max(block))
|
||||
print(max_value)
|
||||
for i in max_value:
|
||||
print(block.count(str(i)), i, len(block))
|
||||
# if block.find(max(block)) + 1 != len(block):
|
||||
# print(max(block))
|
||||
|
||||
|
||||
|
||||
|
||||
# first_max = max(block)
|
||||
# next = block.split(str(max(block)))[1]
|
||||
# # print(first_max)
|
||||
# second_max = max(next)
|
||||
# print(f"{block:<20} | max_value: {first_max}{second_max}")
|
||||
|
||||
49
2025/day03/part2.py
Normal file
49
2025/day03/part2.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# input = "3285251637222363222472154314252527157326423323532213732223724533233636375713623545544337332247253314"
|
||||
# input = """987654321111111
|
||||
# 811111111111119
|
||||
# 234234234234278
|
||||
# 818181911112111"""
|
||||
result = 0
|
||||
|
||||
with open("input.txt", "r") as file:
|
||||
input = file.read()
|
||||
|
||||
|
||||
def cruncher(block: str, minimum: int):
|
||||
print(minimum,block," len",len(block))
|
||||
for i in range(9, 0, -1):
|
||||
print("i -", i)
|
||||
print("сколько",i,"в блоке",block.count(str(i)))
|
||||
if block.count(str(i)) != 0:
|
||||
result = block[block.index(str(i))+1:]
|
||||
print(result," len ", len(result))
|
||||
if len(result)+1 >= minimum and minimum != 1:
|
||||
print(result,"первый выход")
|
||||
return[i,result]
|
||||
elif minimum == 1:
|
||||
print(result," последний шанс")
|
||||
return [i, i]
|
||||
else:
|
||||
print(f"остаток с права от {i} слишком мал")
|
||||
pass
|
||||
else:
|
||||
print(f"в блоке нету {i}")
|
||||
pass # не нашли это число
|
||||
|
||||
for block in input.splitlines():
|
||||
print(f"block: {block}")
|
||||
semiresult = ""
|
||||
reminder = block
|
||||
while len(semiresult) != 12:
|
||||
result_list = cruncher(reminder, 12 - len(semiresult))
|
||||
if result_list:
|
||||
semiresult += str(result_list[0])
|
||||
reminder = result_list[1]
|
||||
else:
|
||||
print("кранчер не вернул результата")
|
||||
break
|
||||
print(semiresult,"len",len(semiresult))
|
||||
print("="*100)
|
||||
print(semiresult,"len",len(semiresult))
|
||||
result += int(semiresult)
|
||||
print(f"result - {result}")
|
||||
139
2025/day04/input.txt
Normal file
139
2025/day04/input.txt
Normal file
@@ -0,0 +1,139 @@
|
||||
@@@..@@....@.@.@@.@.....@@@@@@..@.@@@@@@@@@.@@@@@@..@@@@@.@@.@@.@.@.@..@@@@.@.@.@.@@..@....@.@@@...@@.@@@@...@@@@@@..@@@@@@..@@@@@@.@@..@.@
|
||||
@@@@.@@@..@@@.@.@.@@@@..@.@@..@.@@@.@.@...@.@@@@@@@@@@@.@@@.@@@@@.@@.@@@@@.@.@@@.@.@.@@@@@@..@.@..@@.@.@@@.@.@.@@.@@.@@.@@.@@@@.@@@.@@@.@@@
|
||||
@@@@.@.@@@@.@@.@@@.@.@@@@@.@..@@@.@@..@@@.@@@..@@.@@...@.@@.@@@.@@@.@.@@.@@@@@@.@@.@@.@@.@@.@@@.@@@@@@@@@@@@@@@@@.@@.@.@@@@@@@@...@@@@@.@@@
|
||||
.@@@.@@@@.@@@@@@@..@@..@@.@@@@@@.@@.@@@@@@@.@@@@@@.@.@..@@.@@@..@@.@@@@.@@@@@.@@.@@.@@.@@@@@@@@@@.@@.@@@.@.@@.@@@@.@@@.@.@@@@@@@....@@.@.@@
|
||||
...@.@.@@...@@@@@@@@@.@@.@..@..@@..@@@..@@...@@@@@@@@.@@@.@@....@@@@@@@@@.@@@@@@@@@.@@@@.@.@@@.@@.@@@@@.@@..@@@@..@@@@...@@.@@@..@@@..@@.@@
|
||||
@@...@@.@@@@.@..@@@@.@@@@@.@@...@..@..@@.@..@@@.@@@@@@@@@@..@@@..@@@@..@@@@@@@@.@@@.@@@@.@@@..@@.@@.@@@@@...@@@@@@@..@@@.@@@@@..@@.@@..@@..
|
||||
.@..@@@@@@...@.@@@.@.@@.@.@.@@@@@.@.@@@@@@@@@@@@..@@@@@@@@@.@@.@..@.@@..@@@@..@.@@..@.@@.@@@@..@@@@@.@...@.@@.@@.@@@@@.@..@.@@@@@@.@.@@.@..
|
||||
@@@@@@@@@@@@@@..@@.@...@@.@.@.@@...@@@@@@..@@@@.@@.@@@@.@.@@.....@@...@@@.@...@@...@.@@.@@@@@@..@@@@@@..@.@..@@@@..@@@.@@@@@.@@@@.@@@@.@@@@
|
||||
@@@...@@@@.@@@@@@..@@@.@@.@@.@..@@@@..@..@@@...@@@@@....@..@.@.@@@@@.@.@@@..@@@..@.@.@..@.@..@.@@@.@@...@@@..@@...@@@@@..@@@@@@@@.@@@.@@@@@
|
||||
.@@@@@...@@@@..@@@@@@@...@@.@@@..@@@..@@@.@...@@@.@@@.@@@.@.@@@.@@.@@@@@@@@.@@.@.@@@@@@@.@@..@@.@.@@@@.@@.@@@..@@@@@@.@.@.@.@@..@@@@@.@@..@
|
||||
.@.@@.@..@.@@.@@.@@@@@@@@@.@..@.@@@.@..@@.@.@.@.@......@..@@.@.@@@@@.@@@@@@..@.@@@@...@@@@.@@@@@@@...@@@@.@..@@@@@@.@@..@...@.@@@.@.@@@@.@@
|
||||
@@@@..@@@..@@..@@@@.@.@@@.@@.@@@@@@..@@@@@@@@@.@....@.@.@@@...@.@.@.@@..@..@@@..@..@@@@...@.@@.@@@...@.@@@@.@@@.@.@@@@.@@@..@@@@..@@@@@@@@.
|
||||
@@.@@@.@@@@@@@.@.@.@@@@@@@@...@@.@@@@@@@@..@.@..@@..@@.@.@@.@@@@@@.@@.@@@.@@@@..@.@@@.@@.@@@....@.@@@.@.@@@@@@@@.@.@@@@.@..@@@@..@.@@@@@...
|
||||
@@@.@@.@..@@.@.@@.@@.@.@@@@.@@@@@@..@@@.@@@@.@.@..@@@@@@@@@@@@@.@@@....@@@@..@@@.@@@@.@@..@@...@@@..@@@@@.@@@@..@.@...@..@@.@@.@.@@@@.@@@@@
|
||||
@@@..@@..@.@@@...@@.@@@..@.@@@@@.@@@@@@.@@@.@@@.@@@@@.@..@.@.@@@@.@@.@@@.@@@@.@@..@@...@.@..@.@@@.@@..@@@.@@@@.@...@@@@@.@@@..@@@.@.@.@.@@@
|
||||
@@@.@@.@@@@.@@@@@@@.@.@@.@@@@@@..@.@..@.@@@..@.@@.@.@@@@.@..@@@.@@@.@@@@@@...@..@@..@@.@@@@..@.@.@@@@@.@..@...@..@@...@.@...@..@@@.@..@@@@.
|
||||
@@....@@@@@@@@.@@@..@.@@.@@@@....@@@@..@@.@@..@...@...@@..@@@@..@.@@@.@@.@..@@@@@@@..@@@.@.@@@.@@@@..@@..@@@@@@.@@..@..@.@@@@.@@@.@.@@@@@@.
|
||||
@@...@@.@.@.@@@@..@@@@@@.@.@.@@@@@@@.@.@@.@@...@.@@@..@@@....@@@@.@..@.....@.@@@@@.@@@.@@@@@@..@....@.@@@@@@@.@@.@.@..@@.@@..@@@.@@@@.@@.@.
|
||||
@@@@.@..@@@@..@@.@@@@@.@.....@@@@@..@@@@@@@..@.@@..@.@@@@..@@@@@...@.....@@@..@@.@@.....@@@@....@.@@@..@@@@..@@@@@@.@@@@.@@@..@.@@@.@.@@@..
|
||||
@@@..@.@@.@.@@.@.@@@@@.@@@@@.@@@@@@.@@@.@@@@@.@@@.@@.@.@@....@...@.@@@@@.@@.@.@@@...@@.@...@@.@@@@.@@..@.@@@@@@@.@.@@@@@@..@@@.@@.@@@@.@@..
|
||||
@.@@@@@@@@@@@@..@@@...@..@@@.@@..@@@...@@@....@@@@@..@@@@@.@@@@.@@@@..@.@@.@@@@@.@@@@@..@@@@..@@@@..@@@@@@@@.@@@..@@@@@@...@.@@...@.@.@.@.@
|
||||
@@@@@.@.@@@@.@.....@.@@@@@@.@@..@@@@@@.@.@@@@.@@.@@.@@@@.@@@@.@.@@@..@.@@.@@@@.@.@.@.@@.@@.@@.@.@.@@@...@@.@@@@.@@..@@..@..@.@@.@@.@.@@@@@.
|
||||
@@@.@.@@@@@.@@@@@@..@@..@@@.@@.@....@..@@@@@.@.@@.@@@.@..@@@.@@@@@@..@.@@@@@@@@@@@..@.@@...@@@..@.@@@@@@@@@.@.@@@@@@@@@.@@@..@...@@.@@....@
|
||||
.@..@@@@@@@.@@.@@@@@@@@@@..@.@@@@..@@.@@.@....@..@..@@@@@@@@@.@.@@@..@...@.@@@@....@@@@@..@..@@@@.@.@@@@@@@.@..@..@@..@@.@@.@..@.@@@@.@@@@@
|
||||
@@@..@.@@......@@.@.@.@@@@.@@@@@@.@.@@.@..@@@@.@.@@@@@@@@@@@@@@...@@@..@@.@@@..@@@..@.@.@@@.@.@..@..@@@@@@@@@@@@..@@@@..@.@@@...@@@@@@@..@@
|
||||
@@.@..@..@......@@.@.@@.@.@.@@....@@.@@@@.@@@@@@.@@@@@@@..@.@.@@@@@@@...@@.@.@@..@.@...@@.@@@@@.@@@@..@@.@.@@@.@.@.@@@@@..@@.@@.@.@.@.@@.@.
|
||||
..@@@.@@.@@@.@@.@@@@.@@.@@@@....@@@.@.@@@@@.@@.@@@@..@.@.@.@@.@@@.@@@@@.@.@@@@@.@.@@@.@@@.@.@@@.@@@.@@@.@@@@@@.@@@@@@@..@@@@@..@@.@.@...@@@
|
||||
@@.@.@@.@.........@@@@@@.@@.@@.@@@.@.@@.@@@.@.@@@...@@.@@.@@..@@@@..@@@..@.@@.@@.@..@.@.@@.@@.@.@.@.@.@.@@@.@@@.@@@@@@@.@@@.@.@@.@@@@....@@
|
||||
@@.@@@@@@@..@@@..@.@.@..@@..@.@@@@@.@.@.@....@.@.@@.@@@.@..@@@@@@@@@..@@@.@.@@@@@@.@@@@@.@...@@@@@@@@.@@@@.@@@..@.@...@@.@..@.@@@.@.@@.@.@.
|
||||
.@@@.@@@.@@@.@@..@@@@.@.@@@@@@@@@@..@@.@@..@@@@.@.@@@@@....@@@@..@@@@..@@.@.@@..@@@.@.@.@.@@@..@@.@@.@@@@.....@.@.@@@@..@@@.@@@..@@@.@..@@@
|
||||
@@.@@..@@.@.....@..@@@@@..@.@..@.@.@.....@.@...@@...@.@.@@@@...@@@.@@.@.@.@@.@@.@@..@@.@@...@@@@@.@@.@@@.@@@...@.@.@@@@@@@@.@@@@.@@@@@@..@@
|
||||
@.@.@@@@@...@@@@..@@@@@@@..@.@@@@@....@......@@.@@.@.@..@...@.@@.@@@..@@@@..@@@..@@@.....@@@.@@@@@.@@@@@@@@@@@@@@@@@@@.@@@@@@@..@.@@.....@.
|
||||
@@.@@@@@@@...@@@@.@.@@@@@..@@@@@.@@..@@@@.@@@@@@@@@@..@@.@@...@.@.@.@@@@@@@@@.@@..@@@@@.@@@.@@@.@@..@..@@@@@.@@@@@.@@@@.@@.@@.@.@.@@@.@.@@.
|
||||
......@@@@.@@@@@@@@@@@@@@.@@@@@@@@.@@@@@@.@@..@@..@@@@.@@@@@@@..@@.@.@@@@@@.@@@.@@@@@.@.@@@.@@@@.@@@@@@@.@@@@@...@@@.@@..@@...@@.@@...@@..@
|
||||
@@@.@.@@@@@.@.@@.@@@.@@@.@@@@@@..@@@.@.@@.@@...@@@@..@@@.@.@.@..@@.@@.@@@@@@.@.@.@@.@@@..@@@@@..@@@..@@..@@.@@@@.@@@@@.@..@.@@@.@...@..@@@@
|
||||
@@@@.@.@@.@.@.@.@@@@@@@@@.@@.@@@.@@@@@@.@@.@..@@.@.@.@@@@@@@@.@@@@@@@.@...@@@@@@@@.@.@.@@@.@@@@@...@@.@.@@.@@.@@.@.@..@..@.@.@@.@.@...@.@.@
|
||||
@@@.@@@.@@@.@.@..@..@@@.@@@.@@@@.@.@.@.@@...@..@..@@.@@@.@@.@..@@@@@@@.@@.@@@.@@@@...@@.@@@@@@@@.@....@...@..@.@@@@@@...@@@.@.@.@@.@@@.@@@.
|
||||
@.@@@.@.@.@@@@..@.@@@@@@@@@..@@@@@@@.@.@@@@.@@..@@@..@@..@.......@@@.@@.@@@@.@.@...@@@@.@@@@@.@@..@@@@.@@@@@@@@@@...@@@@.@@.@@.@...@@@@@@..
|
||||
@@....@@.@@...@.@..@@.@@@.@.@@.@@@@@@.@@.@@@@@@.@@...@@@@@@@@@@.@..@.@...@@..@@.@.@.@@.@@.@@..@@@@.@@.@@.@@.@@@@@@@@@@.@.@@.@@.@@@@@@@.@@@.
|
||||
@@..@.@@@@@@@.@@@@@...@@@.@@@.@@.@@@.@@...@@..@@@.@@@@@....@@@.@@@@.@@@@.@@.@.@@.@....@@..@.@.@@@.@..@@..@.@@.@..@..@.@@.@@..@@..@@@..@@.@.
|
||||
.@@@@.@@@..@@@@@@@@...@@@......@.@.@..@@@@@@@.@@@.@@.@@@@@@.@@@@..@@@@.@.@@@@@@...@.@.@@@.@@@@..@@@@.@.@@@.@.@.@@@..@@..@@@....@.@@.@@.@@@@
|
||||
@@@@@@@@@@.@@...@@@@@@@.@@@@@...@.@@@.@@.@@@@.@@..@.@@@@@@@@..@@@@..@@@@@.@@@@@@@@@.@..@@.@@.@..@..@.@@@..@.@..@@@@@@..@.@@@.@@@.@@.@@..@@@
|
||||
.@@@.@@..@..@.@.@@@@@@..@@@.@@@@@@@@@@@@.@@.@.@@.@..@@@@@..@..@@@.@@@@@...@@@@@.@.@@@@...@@@@@@..@@@@@@.@@.@@.@...@@.@.@@....@....@@@@.@@..
|
||||
@.@...@..@@@.@@@@@@@.@..@..@@@@@.@@@@.@@..@@..@@@@..@@@@..@@@.@@..@@@@.@@@@.@@@@@@@.@....@....@@..@@@@@@.@..@..@@@@...@@@@...@@@@@....@@@.@
|
||||
@.@@..@@.@@.@@@.@.@@@.@@@@@@@.@@@@@.@...@@@@@..@....@@@.@.@.@@...@@...@@@..@.@..@@.@@@@@@@.@@...@@@.@@@@@@@@.@@.@.@@@.@.@.@@.@@@@@.@.@@@..@
|
||||
@.@@@.@@@@@.@@@@@@.@@@@@@@..@@@.@@@.@..@@@@@.@..@......@..@..@@@@@..@@@..@@@.@..@@@..@.@.@..@.@@.@@@.@@@@.@.@@@@.@@..@@@..@@@@@.@@..@@@@@.@
|
||||
@.@@@.@..@@.@.@@@.@@@..@..@@@...@@@@@@@@@.@@@.@@@@@@..@@.@@@@@.@@@@...@....@.@@..@@@@@@@@@...@@.@@@..@@@@.@.@..@@@@@@.@@@@@@@@@@@@...@@..@@
|
||||
@@@@..@.@@@@@@@@..@@.@@@.@@.@.@@@.@.@.@@@@@@@....@.@@.@@@@@@@@..@.@..@@.@@@@@@@.@@@.@.@@@@..@.@.@@.@@@@@.@@.@.@..@@@.@.@@.@..@@..@@@@.@..@.
|
||||
@@@@.@.@.@@.@@@@@@..@.@@@.@.@@.@@@.@@.@.@.@@@..@@.@...@@.@@@@.@@@@..@..@.......@@.@@@@.@.@@..@@@@@@@@@@@@.@@.@@.@@@@@@@.@@@..@@..@@..@@@.@@
|
||||
.@@@@@@@@@.@@..@.@@.....@.@@.@.@@@..@...@.@@@@@@@.@@.@@...@.@@....@@@..@@@@@@@@@@@@@@@@@.@@@@.@@@@@@@@..@@@.@@@..@.@..@@......@@@@@@..@@@.@
|
||||
@@@@.@..@..@@.@@@..@@@.@@@@@@.@@@@@@.@@..@..@@.@@@@.@...@@@.@@@..@@.@..@@@.@.@@@..@@@..@@@@..@@..@.....@..@..@..@@@@@@@...@.@@@@@@..@.@@.@@
|
||||
.@@@@@@@@@@.@@@@@@.@.@@@@.@@@@@@.@@@@@@@@@@@.@..@@..@@@.@@@@@@@@@...@..@.@@@@@@@@@.@@@...@@..@.@@..@@@@@@.@..@@@@@@@@.@@@@@@@@@@..@@@@@@@@@
|
||||
.@..@..@@@.@@...@.@@.@.@...@@@...@@@@.@@@@@@@@@.@@@@@@@.@@@@.@.@@@@@@@....@.@@@@@..@@......@@.@@@@.@@@@@@@@.@.@..@@..@@..@@.@@.@@....@@@.@.
|
||||
@.@@@@..@@@@.@@.@@@@@@.@.@.@@@@@@@..@@@@@@@@..@@.@@@@@@@@.@.@.@@@.@@.@@.@@.@@@@@@.@..@...@@@@@@.@.@@@.@@@@@@@..@@@.@@@.@.@.@@@@.@@@@@@@..@.
|
||||
.@@@@.@@...@@@@@@@@@..@@.@@..@@@...@@@@@.@@@@...@@@@.@@.@..@@..@@@@@@@.@.....@.@@..@@...@@..@.@@@@@.@.@.@.@@@.@@@@..@..@@@@@@@@@@@@.@.@..@.
|
||||
@.@@@.@.@@@@.@.@.@.@@@.@@..@@@@.@@@@@@...@.@.....@@.@@@@@...@@..@@@@@@@@@@@@@@..@..@.@@.@@@.@@..@.@.@@@@.@@@@..@@@..@@@..@.@@@@.@@.@.@@@.@@
|
||||
.@.@@@@@@@@@@@@@.@@@.@..@@.@..@@@@.@@@@@@@..@...@@@@@...@@.@.@@@@..@.@@.@@@@.@..@@.@.@@@..@@@@@..@@@@@@@@@.@.@@@@@@@..@.@@.@..@@.@@@@@@@@@.
|
||||
....@@@@@@@.@.@@@@@@@@...@@.@..@..@..@@@@.@@.@@@@@@@@@@...@.@.@...@@..@.@@.@@.@.@.@.@.@@@...@..@@@@.@@.@@@......@..@@@@@...@.@@@..@@@@.@@.@
|
||||
@@@@.@@@@@@@.@.@@@@@...@..@..@@..@@@@.@@@@@@.@@@@@.@.@.@@.@@.@@@.@@@.@@@@@@@@..@@..@@@@@@@.@@@@..@.@@.@..@@@@@@..@@..@...@@@@@@.@@@@.@@@.@@
|
||||
.@@@@.@@@@.@@@@.@@@.@@@@...@..@.@@.@@..@@@@@.@@.@.@@.@@@@@@.@.@.@@.@@..@.@@.@@@@.@....@@@@@@@@@@@@..@@..@@.@@..@@.@@.@@@.@..@@@@.@@@.@..@@.
|
||||
@@...@@@@@@...@@@@.@@@..@....@...@..@@@@..@@@.@.@..@..@.@@@...@@@@@@@@@@.@@@.@@@@..@.@@...@..@@.@...@@..@@@@..@.@@@..@@.@@.@@@@@@@@@..@@@.@
|
||||
@.@@@..@@@@@@@@@@.@.@@.@.@@.@...@@.@.@@.@@@@@.@@@@@@.@..@.@@@@.@@@@.@@.@.@..@@@@.@@@..@@..@@@@@@@@.@@.@@.@@.@.@@.@..@@@@@@@@.@@.@@.@.@..@..
|
||||
@.@@@@@.@.@....@@@@..@.@@..@..@@@@@@@@@@@@@@.@@..@@@@@@@@..@@@.@@@@@@@@@@.@..@.@@.@@@@@@@..@@@.@@@@@@@@.@.@@.@@@@@@@@.@@@.@@@@.@@.@..@@@@@@
|
||||
@@@...@@@@.@@@@@@@@@@.@@.@.@@@@@@@@.@...@@@.@.@@.@@...@@@@@.@@@.@.@.@.@@@@@@..@@@@@@@..@@.@@@@@.@..@@.@.@..@@@.@...@@.@@..@@..@@....@...@.@
|
||||
@.@@.@@@@..@@@@.@@@@@.@@...@@@@@@@@.@..@@..@@@@@@.@@...@.@.@..@@@@...@.@@@@......@@@.@@@@@.@.@.@@.@@@@..@@.@....@@..@@.@.@@..@.@.@@.@@@@.@@
|
||||
.@@@@.@.@@.@.@@@@.@@...@@@@@@.@.@@@@@.@@.@..@..@...@@..@@@@@.@@@@.@@@@@..@@.@@.@@@@@..@@.@@@@@@@..@@@....@@.@..@@.@@..@@@@@.@@.@@.@@.@.@...
|
||||
@@...@@.@@@.@.@@..@@@...@@.@..@@@.@@@@@.@@@.@@@.@@..@@@@@..@.@@@@@@.@@..@.@.@@@.@@.@@@.....@@..@.@@@@@...@.@@.@@@.@.@.@@@..@@.@@.@..@.@@.@@
|
||||
@..@..@@.@.@@.@.@@.@..@@.@..@@@@@@..@.@@...@...@..@.@@.@@@@.@@..@.@@@@@@@@.@@@.@.@@..@@@@.@@@.@@@@.@@@@@.@@@.@@@@@.@@@..@.@.@@@@..@@@@.@@.@
|
||||
@@@..@@.@.@@.@@..@@@@@.@.@.@@@@@@..@@@@@@.@@.@@@@.@..@@.@@@.@@@@@...@@@@@...@@@.@@..@@@@@@@...@@@@@@@@@@@..@.@.@@@@@....@@@@@@..@.@.@..@.@@
|
||||
@..@...@@@....@.@..@..@..@..@@.@@@@@@@@@@@.@.@@@..@@.@@..@.@.@..@@.@.@@@@@@.@@@.@@..@@.@@@@.@@@.@@@.@@.@@@.@.@@@@@@..@@.@..@@.@@@@@.@@@.@@.
|
||||
@@@@@@@@@@.@@@@@..@@.@.@@@@@.@.@@@.@@@.@@..@@@@.@@@@..@@@@@@...@@@@@.@@@.@@..@..@@@@.@.@@@@@@@..@@@.@@@@@@@..@.@@.@@@.@@.@.@.....@.@@.@.@@.
|
||||
@@@@@@@@@.@@@@@@@.@@@..@@..@@@....@@...@@..@...@@.@@@@.@@@@@@@@@@..@..@..@.@@@@.@@.@@.@@@@@@@@.@....@@..@@@@.@...@@@...@@@@@@@@@@@@@.@@.@@@
|
||||
..@@@@.@.@@@@@@@@.@@.@@@@@.@.@@@.@.@@@.@@@@@@@@@@.@...@@@.....@.@@@.@@@.@@@@@.@@@@...@@@@@@.@@...@@@...@@@@.@.@.@@@@@@@@@.@@....@@@@.@@@@@@
|
||||
@.@@@@@.@@@@..@.@.@@..@@@@@.@@@@@@.@@...@.........@.@@@......@@..@@@@...@@.@.@..@.@.@.@@@@@.@@...@.@@@.@@@@..@.@@@@@.@.@@.@@@.@@@@@.@@..@@@
|
||||
.@@..@@.@.@..@@@@@.@@.....@@.@@@@@.@.@.@@.@@.@..@..@@@@@.@..@@..@@.@.@@@@@@@@@@@@@@..@@.@.@@@@@.@@..@@.@.@@.@@@@@.@@@@.@@@.@@.@@.@@@.@@@@@@
|
||||
@.@@@@..@.@.@@...@@@.@@.@@.@@@@@@@@@.@@@@.@@@@@..@@@@@.@.....@@@@@@...@..@@...@@@@@@.@@..@.@.@.@..@@@.@@@.@..@@@.@.@.@@@@.@@....@@@@@.@@@@@
|
||||
@@.@..@@@@@@@@@@.@.@@@@@@@@.@.@..@@@....@.@@@..@@.@@..@@@@@.@@@.@@@@@..@@.@@@@.@@@.@@.@@@.@...@@@@@@@@@.@.@@.@@@@.@....@@.@.@.@@@@@@@@.@.@@
|
||||
@.@.@@@@@@@.@..@@@@.@@@@@@@@.@@@@@@@...@@@@......@@@@@@@@@@@@@..@@@@@@@..@..@@@@@@@@.@.@.@@.@.@.@.@@@@@...@@@@@@.@.@@.@...@@@@@@@@@@@.@.@..
|
||||
..@@@@.@@@@@@@..@.@@@@@@..@.@...@@@.@@@@..@@..@@@@@@@.@@.@.@@@@@.@..@@@@.@@@@@..@@@@@@@@.@@...@@@...@.....@@@..@.@@..@..@@.@.@@@@@@@..@@@@.
|
||||
@@..@...@..@..@..@@@....@@.@..@@@@@@.@@@@.@.@@@@....@@.@@@.@@@.@.@@@@@.@@@.@...@@@..@@@.@@..@@@@@@@.@@@@@@@@..@@@@.@@@.@.@@@.@@..@@..@@.@@.
|
||||
@@@@.@@@@..@@@.@.@@@@.@.@.@.@@.@.@...@...@.@@..@@..@@@..@@@@@.@@.@@.@@..@@@@@..@.@@.@@..@@@.@@@...@@.@..@@.@@...@@.@@@.@@@@.@@.@..@.@..@.@.
|
||||
....@@@..@.@..@@@.@@.@..@@@...@.@..@..@@....@@@@@@.@@.@@@@@@@.@@.@@@@..@.@@.@.@.@.@@.@.@@@@.@@.@.@@@...@.@.@.@@@@.@..@@..@@@..@@@@@.@..@@..
|
||||
@@.@@@@..@@@@@@@@@@..@.@@..@@@@@.@@.@.@.@@@@...@@@@@.@.@..@@.@@@.@..@.@.@@@@.@..@@@@.@@.@..@.@.@@.@@@@@@@@@@@@.@@@.@........@@@@...@@@..@@.
|
||||
.@@...@@.@.@@.@@@.@.@@@@.@@@@@...@@@@@..@.@.@@@...@....@..@@..@@...@@.@.@@.@@.@.@@@.@.@..@@.@.@...@@.@...@@.@.@..@..@@@@.@@@.@@.@.@@.@@@.@@
|
||||
@@.@@@..@.@@.@..@@@@@.@@.@@..@@..@@@.@.@@...@.@@.@@.@@@@@@@.@@@.@.@.@@@..@...@.@.@..@@..@.@..@@@@@@@@.@.@@@@..@@@..@.@.@@@.@@@@..@.@@@@@@.@
|
||||
..@..@@.@.@@.@@@@@@@@.@@@.@.@@..@....@@@@@@@.@@...@.@.@@@@@@.@@.@@@@.@@.@@.@@..@@@...@@.@.@@@.@@@@.@.@.@@@@@@@@@@@@.@....@.@.@@@@@@@.@@..@@
|
||||
@..@@.@.@.@.@@@@.@@...@..@..@.@.@@.@.@@.@@@@@.@@.@@@.@@@.@....@@@@@@.@.@.@@.@@@@@.@@@.@@@..@@@.@@..@@@@@...@.@@.@.@@.@@...@@.@@@...@@@@@@..
|
||||
@..@@@.@@.@.@@.@@@@@@@@.@@@@@@.@.@@@.@...@@@.@.@@.@..@@@.@.@.@@@@@..@@.@@.@@@@.@....@.@@@@.@..@@@@@@..@@@...@@@.@.@.@@@@..@..@..@@.@@.@@..@
|
||||
.@@@@@@@.@.@@@@..@.@.@@@...@@@.@@@@@@@@@@@@.@....@@.@@@@@@@.@@@.@@..@@@@@@@.@.@.@@.@@.@@@.@@@...@@@@.@@@@@@@@@@.@@.@@@@@@..@.@.@......@@@@@
|
||||
..@..@@.@@@.@@@.@@@@@@@@@@@@@@@.@@..@.@@.@.@@@.@@..@.@@@@@@.@@@@.@@@@@.@@...@@@@..@@@@.@.@@@@@@.@@..@.@.@@.@.@.@@@@..@@.@@@@@.@@@@@@@@@@@@@
|
||||
@@@.@@@@@@@@.@@@.@...@@.@.@..@.@@@@@@@...@@.@.@...@.....@@@@.@@@...@...@.@.@@@@@@@@@@...@@@..@.@.@@@@....@@@.@@@@@@@@@@.@.@.@.@@.@@@@@@..@.
|
||||
..@@@@@..@@@.@@@....@@@@@@@@@@@@@@@@@..@@@.@@@@@@@..@@@@@..@@@..@@@@.@@@@@.@.@...@.@.@.@@@..@@.@@@.@@@@.@.@.@@.@@@.@@.@@@..@.@.@@.@@@@.@@@@
|
||||
@.@@..@.@@@@.@.@..@@@@@@@@@..@@@.@@.@@.@.@@@@@@@@.@@@@@..@@@@@@@....@.@.@@@@.@@@@@@@@.@@@@@.@.@@..@.@@@@@.@@@@.@@.@@@@...@@.@.@@@@@@@.@@@..
|
||||
@.@@@@@...@@@.@.@.@.@.@.@@@.@@..@@@@@@......@@...@@@@.@@@@...@..@@@.@...@..@@@@.@@@@@@@@@@@@.@.@@.@@@@@..@.@@...@@@@.@@@@@.@.@@..@@.......@
|
||||
@.@@..@@@@@@.@.@@@.@..@@.@@..@@.@.@@@@@@.@..@@.@@@.@.@.@@.@@.............@@@@.@@@@.@..@..@@.@@@@.@@@.@.@...@@.@..@@@@@.@@.@@.@@@@..@..@@..@
|
||||
@@@@@@@..@.@@@.@@@@...@@@@@@@@.@.@.@@@..@@@@.@.@@.@@@.@@.@.@@@@@@@..@.@....@.@@@@@@.@@.@..@@@@@.@...@@@.@.@@@..@..@..@.@@@@..@.@.@@@.@...@.
|
||||
@@@@.@@@.@@@@@@@@@.@..@.@@..@@..@@.@@.@@@@@@@@@.@..@@@.@@@@@@@.@@@@.@@@.@@@@@@.@@@@@.@@@.@@@@.@....@.@.@@.@@..@....@@@..@..@@..@@...@@.@@.@
|
||||
@@@..@@@@@@@@@..@.@.@@.@@@@@@@@.@..@@@........@@@@.@@@@.@@@.@@@@@.@.@@@.@@@@@.@@@@@@@@..@@.@@@@...@.@@.@@@@@.@@...@@...@@@@.@@@@....@.@@@..
|
||||
....@@.@@@.@@@..@@....@@@@.@@@@@.@@.@@@@...@@..@@@@.@@@.@.@.@@.@@@.@@.@@@.@@@.@.@..@@.@@@@...@@@@@@@..@@@@@@@.@@..@@@...@..@.@.@@@@..@.@@.@
|
||||
@.@@@@@.@@....@@@@@@@@.@.@..@@@@.@..@@@@..@@@...@@..@@@@....@@....@@@@@@@.@@.@@@.@@.@@@@@..@@@@@@@@@.@@.@@@@@@@@@@@..@@@..@.@.@@..@.@@@@...
|
||||
......@@@.@..@@.@@@@@@.@@@.@@@.@@@@@@...@@@@@@@.@.@@@@@.@@.@@@@.@.@@@@@.@@@.@..@@....@..@@..@@@..@.@@@@@@@.@@@..@...@@@@@.@@@..@@...@....@.
|
||||
@...@@@@.@@@.@....@@..@@@@.@@.@@@@.@@@@@.@@.@@@@@@@@@@..@@@@..@@@@@@@@.@@@.@@@@@@@.@@...@@..@.@@@@.@@@@@@@@@@@.@.@@.@...@@.@@..@@@@@..@@@@@
|
||||
...@@.@@@@@@..@@@@.@@..@..@@@@@@@@@...@@@@..@.@@...@@@@@..@@.@@@@.@@@@@.@@.@@..@@@@.@@@.@@.@@@.@@.@.@@@.@.@.@.@@@@.@..@.@@.@@@@.@..@@@@.@..
|
||||
@.@@.@@.@@@@@@@@.@@@.@@..@@@.@..@@..@...@@@@@@@@@@@@@@.@..@..@@@@@@@.@@.@@..@@@@@@@@.@@@@@@@.@@@@@@.@.@@.@.@.@@..@@@.@.@@@.@.@@@@@@....@.@.
|
||||
..@@@@@@@@...@@......@@.@@@.@..@@@@@@@@@@@.@..@@.@@@@@.@.@@..@@..@.@@@.@@.@.@@..@.@..@.@.@@.@@@@.@.@..@.@@@..@..@@@.@@@@@..@@@.@@.@.@@@@@@@
|
||||
@@@@@@@@@@@...@..@..@@@...@@..@@...@@@@.@@.@@@.@@@@.@@@@@@.@.@@..@@..@.@..@.@@@..@..@..@@...@.@@@..@@@.@...@..@.@...@@..@.@@@@....@@@@.@@..
|
||||
@@@@..@@@@.@.@@@@@@@.@@.@...@@@...@@@...@.@....@.@@@@@@@.@@@.@@@@@@.@@...@.@@.@@@@@.@@..@@@@.@@@..@@@..@.@..@@@.@@@@...@@@@.@@.@@@@@@@@@.@.
|
||||
.@@@.@@..@.@@@@@.@@.@@@@@.@@@...@@.@@..@.@@@....@.@.@@@..@@.....@@..@@@@@@.@@@@.@.@....@@@@@@....@.@@.@.@@@@@@..@@@@@@@@@@@@.@@@.@.........
|
||||
.@@@..@@@.@@@@@@@@@@....@@@.@@@.@.@...@.@@@@.@.@@@..@@..@@....@@@.@@@....@@.@@.@@....@@.@@.@@.@.@@...@@@@@@@@@@@@@@@@@...@.@..@.@@@.@@@.@.@
|
||||
@@@@.@@@.@..@@@...@@@@@@..@.@@@..@.@@@.@..@.@@.@@@.@@@@@@@@@..@.@@@@..@@..@.@.@@.@@@@@.@@@@...@@@@@.@@@..@@@@@@@@@..@@.@@@@@.@.@@@@@@@@@@@@
|
||||
@@@.@@.@..@@@.@@@@@.@@@......@@@@@@.@.@.@@@@@@.@@@@.@@.@@..@....@@@@@..@@@@@@@@@.@...@@@@@@..@.@.@@@@..@@@@..@@@@@@..@.@.@@.@@@@.@@.@.@@@@@
|
||||
.@@@@@@@@.@@.@@@@.@@@@....@@.@.@@.@@@@@@.@@..@@@.@@@@.@@.@.@@@@.@@@@@@...@@@.@@...@.@.@@...@@@@.@.@.@.@@@@..@@.@..@@..@@.@@...@@.@@.@.@.@@@
|
||||
...@..@@@@..@....@@@..@@..@@.@.@.@@..@@@.@.@@.@@@.@.@.@@...@@@@@@@@.@@...@@@@.@@@@@.@..@@@..@.@@.@..@@.@@..@@@.@..@@....@@@@@.@.@..@..@.@@.
|
||||
@.@..@.@@@.@@@@@@..@@@.@.@....@@@..@..@.@@@.@@@..@@@@@@@@.@.@.@@@@@@@@@@@@...@.@@@..@@@@@@.@...@@@.@.@@.@@.@@@@@@@.@@@@@....@@@@@.@.@@@@@@@
|
||||
@@@@@@..@@....@@@@@...@@.@.@.@@@@.@.@...@@@@@@..@@@.@@@@@@.@@@..@.@@.@@@.@@....@@..@@@@@@@@@.@@@..@.@.@@..@@@@@.@@@.@@..@.@.@..@.@@.@@@.@@@
|
||||
.@.@.@@@@@@....@@.@@@@.@.@.@..@.@.@.@@@@.@.@@@@@@@.@..@.@.@...@@@.@@@@@.@.@@..@@@.@@@.@@@@..@@@@.@@@@@...@.@...@@@..@@@@@@.....@@@@@@@.@..@
|
||||
..@@@@@@.@..@@@.@@...@@@@@@..@.@.......@@@..@.@@@.@@.@@.@@..@@.@.@.@@@@.@.@@@.@.@@@@..@.@.@..@@.@@.@...@@@@@.@.@@@@.@@@.@@.@.@@.@@@@....@@@
|
||||
.@.@.@@@.@.@...@@.@.@@@@.@@@@@@@@@.@@@...@@@.@@@.@@.@.@@@@@.@.@@@..@.@..@@@@@.@@@....@@@.@@@@@@@.@@@@..@.@.@.@..@.@@.@.@..@.@@@@@@.@..@.@@@
|
||||
.@@@@@@@@..@@@.@@.@..@@.@@@@@.@..@@.@@@@.@@.@..@@...@@.@@@.@@@.@..@..@.@@@@@@..@.@@@..@@...@@..@@@@@@@@@.@@@.@@..@.@.@...@@@@@@@@@.@@@@.@..
|
||||
..@..@@@@@.@....@@.@..@@@.@.@@.@@@@.@@..@@@@@.@@@@@@@@@@..@@@@.@.@@@.@.@@@@@@.@@.@@@@@.@.@....@.@@@....@@.@@@.@@@@@@@@@@@@.@@@..@@..@..@@..
|
||||
@.@@.@@.@@@.@.@@@@.@.@@..@@@..@@.@@..@@@.@@@..@...@@.@@@.@@@.@@@.@@@@@@@..@@@@@.@@@..@.@@@@...@@.@.@@.@..@@@@@@@@.@..@..@@@@@@@@@..@.@@@@@@
|
||||
..@@@@@@@@@@@@@.@@..@@@@@@@@@@@@..@@..@@.@@.@.@....@@.@.@@@@@.....@.@@@.@@@@.@@@@.@.@.@@@.@@@@@.@@@@@.@.@@@@...@@@@.@.@@@@..@@@.@.@@@@@@@@@
|
||||
@.@.@..@@@.@.@@@.@.@.@@.@@@@@.@@@@...@@@@@@.@.@@.@@@.@.@@.@...@@...@@@@..@@.@.@@.@@@.@@@@...@..@@@..@.@@@..@@@.@.@.@@@@@@@@@@@@@@@@....@@@@
|
||||
@@@@@.@.@@@.@@.@@@@.@@..@@@@@@@@@@@.@.@@....@@@.@@@.@.@.@@.@@..@.@@@@@@...@@..@@..@.@@@.@..@.@@@@@@.@.@@@@@@@@@@@@@@@@..@.@@@@@...@..@...@@
|
||||
@@@@..@@..@@@@@@.@@@@@@.@@@@@@@.@@.@@.@..@.@.@@@@.@...@@.@@.@@@@.@@@@.@@.@..@@.@@.@..@.@@@.@.@@@@..@..@@..@.@@.@@@@@@@@..@@.@.@@...@@@@@@..
|
||||
@@@@@@...@.@@.@.@.@@.@..@@.@.@@@....@@@..@@@@@@@@@@.@..@.@@@..@.@@@@@.@@@@.@@.@.@@@@..@@@.@..@@...@@@@.....@..@@@..@@@@@.@.@@.@@...@@.@..@@
|
||||
.@..@@.@@@..@@@.@...@.@@.@@@@@@@@.@.@.@@..@.@@@@@@@@@.@@.@@@@.@@@@@@.@@@.@@@@@@.@@@@@.@.@@.@@@@@@.@@@..@.@.@.@.@@@.@@@..@@@.@....@@@@@@.@@.
|
||||
.@@@......@.@@.@@@..@@.@@@@.@.@@@.@@.@..@@.@@@@.@@.@@@@@@...@@@.@@..@...@@@@@@@@@.@@@..@@..@@@@.@..@@@@@@@.@@@@@.@@@@.@......@...@...@@@...
|
||||
@.@@@@@.@@@@@@@@@@@@.@@@@@...@@@.@@.@@.@@.@@..@.@@...@@@@@@@.@@...@.@@...@@@.@.@@@.@..@@.@@@..@@.@@@.@@@@@@.@..@@.@.@.@@.@@@@@@@@@.@..@@@@@
|
||||
@.@@@@@..@@.@@...@@@@@.@@.@@..@@..@.@@.@.....@@..@..@..@@@..@.@@...@.@@@@@@@@.@@.@@@..@@@.@@.@@@@.@@@@@@@@.@@@@@@@@@.@@..@@.@@@@@@@@@..@@..
|
||||
..@@@@.@..@@@@..@@@.@@@@@.@..@.@.......@@@@@.@@@..@@@@@.@@@@..@@@..@.@@@.@@@@.@@.@@.@@@.@@@@@@@@.@@@@@.@@@..@@@@.@.@..@@..@.@@@.@.@.@....@.
|
||||
.@@@.@@.@@@@..@@@.@@@.@.@@@.@@.@@.@...@.@@@@@.@.@.@@@@@@@.@@@..@..@........@@@@@@.@@@@@@@@@@@@..@.@@@@@@@.@@.@@..@@@.@@@@..@.@.@..@@..@@.@@
|
||||
@@@@@@.@@.@.@@.@@@@@.@@@.@..@@@@@@@..@..@@@@@@@@@@.@@@.@@@@@...@@@.@@@.@@@@@..@@.@@..@.@@..@.@@@@@@@...@.@.@@@@@.@@@@.@@@.@.@@@@@.@.@@.@.@@
|
||||
@@.@@@@@..@...@@@@.@..@@@@@@.@@@@.@@@@..@..@.@....@..@.@@..@.@.@@.@@.@@@@@@@@.@@..@@@@@@@..@.@@..@@.@.@.@@@@.@@.@..@...@@@..@@@@@...@@@.@.@
|
||||
...@@.@@..@@@@@@@@..@.@@...@@@.@@.@.@.@@@@@@@.@@@@@@@@.@@..@@@.@....@..@@@....@..@@.@@@.@@@@.@@.@@@@@.@@@@@@@@@@@.@@@@...@@@@@...@@@@@.@@.@
|
||||
...@@.@@@@@@...@.@@@@@@...@@@.@@.@@@@@@@@.@@...@@@@.@@@....@@@@@@.@@@..@..@.@..@.@@@@@@......@@@.@.@..@..@@.@@@@@.@@@.@@@.@.@@.@@@@@.@@@@@@
|
||||
@@@@..@@@..@@@.@@@@@.@..@..@@@@.@.@@.@@@@@@@@..@@@@@@@@..@.@.@@@@.@@.@@@.@..@@@@.@...@@@......@@@@@...@.@@.@@@..@@.@@..@@.@@@@..@@@@@@@@.@@
|
||||
@@..@...@@@.@..@@@@@.@@.@@.@..@..@@.@@@@@@..@@@@.@@@.@.@@.@@@@@@@@..@@@@.@@@@@@@@@@.@@...@....@.@.@@..@@@......@@@@@@@@@@.@.@@@@@@@.@...@@@
|
||||
@..@@.@.@@..@@@@..@@..@.@@..@@@@@@@@@.@@@...@.@@@@.@@@@@@@@@.@...@@...@.@@@.@.@@@.@@...@@@@.@@@.@.@..@.....@@.@@.@@.@@...@@@@@@@@@.@..@.@@@
|
||||
83
2025/day04/part1.py
Normal file
83
2025/day04/part1.py
Normal file
@@ -0,0 +1,83 @@
|
||||
# Читаем инпут и создаем масив состоящий из списков в списке
|
||||
# Х это первы список и "вертикалб"
|
||||
# У это подсписок с "горизонталь"
|
||||
input = """..@@.@@@@.
|
||||
@@@.@.@.@@
|
||||
@@@@@.@.@@
|
||||
@.@@@@..@.
|
||||
@@.@@@@.@@
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
@.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
@.@.@@@.@."""
|
||||
|
||||
# with open("input.txt", "r") as file:
|
||||
# input = file.read()
|
||||
|
||||
karta = []
|
||||
for row in input.splitlines():
|
||||
karta.append(list(map(str, row.strip())))
|
||||
|
||||
for row in karta:print("".join(row))
|
||||
|
||||
# проверка существования поля
|
||||
def fild_exist(x:int,y:int):
|
||||
|
||||
if x < 0 or x > len(karta) -1:
|
||||
return False
|
||||
elif y < 0 or y > len(karta[x]) -1:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
# Функция проверки
|
||||
def cheker(x: int, y: int):
|
||||
roll_count = 0
|
||||
filds_to_check = 9
|
||||
# print(f"cheker for {x} {y}")
|
||||
# print(f"roll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
while (int(roll_count) >= 4) is False or (filds_to_check <= 0) is False:
|
||||
# print(f"Предположительные координаты для range: x {list(range(x - 1,x + 2))}, y {list(range(y - 1, y +2))}")
|
||||
for n_x in list(range(x - 1,x + 2)):
|
||||
for n_y in list(range(y - 1, y +2)):
|
||||
# print(f"Существует поле {n_x} {n_y}? {fild_exist(n_x,n_y)}")
|
||||
if fild_exist(n_x,n_y):
|
||||
if karta[n_x][n_y] != "." and not (n_x == x and n_y == y):
|
||||
roll_count += 1
|
||||
filds_to_check -= 1
|
||||
# print(f"ADD +1 to roll_count\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
elif n_x == x and n_y == y:
|
||||
# print(f"Do not self chek!!!\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
filds_to_check -= 1
|
||||
else:
|
||||
# print(f"field has a .\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
filds_to_check -= 1
|
||||
else:
|
||||
# print(f"FIeld dos'n exist\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
filds_to_check -= 1
|
||||
# print("FINAL roll_count =",roll_count)
|
||||
# print(filds_to_check <= 0)
|
||||
# print("="*100)
|
||||
return roll_count
|
||||
|
||||
|
||||
# Основное тело
|
||||
result = 0
|
||||
|
||||
for x, val_x in enumerate(karta):
|
||||
for y, val_y in enumerate(karta[x]):
|
||||
# print(f"проверяем координаты: x={x}, y={y}")
|
||||
if karta[x][y] != ".":
|
||||
if cheker(x, y) < 4:
|
||||
karta[x][y] = "x"
|
||||
result += 1
|
||||
# print(f"cheker for {x} {y} is {cheker(x,y)}")
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
print("="*(len(karta[0])))
|
||||
for row in karta:print("".join(row))
|
||||
print("Result",result)
|
||||
115
2025/day04/part2.py
Normal file
115
2025/day04/part2.py
Normal file
@@ -0,0 +1,115 @@
|
||||
# Читаем инпут и создаем масив состоящий из списков в списке
|
||||
# Х это первы список и "вертикалб"
|
||||
# У это подсписок с "горизонталь"
|
||||
input = """..@@.@@@@.
|
||||
@@@.@.@.@@
|
||||
@@@@@.@.@@
|
||||
@.@@@@..@.
|
||||
@@.@@@@.@@
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
@.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
@.@.@@@.@."""
|
||||
|
||||
with open("input.txt", "r") as file:
|
||||
input = file.read()
|
||||
|
||||
karta = []
|
||||
for row in input.splitlines():
|
||||
karta.append(list(map(str, row.strip())))
|
||||
|
||||
for row in karta:
|
||||
print("".join(row))
|
||||
|
||||
|
||||
# проверка существования поля
|
||||
def fild_exist(x: int, y: int):
|
||||
|
||||
if x < 0 or x > len(karta) - 1:
|
||||
return False
|
||||
elif y < 0 or y > len(karta[x]) - 1:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
# Функция проверки
|
||||
def cheker(x: int, y: int):
|
||||
roll_count = 0
|
||||
filds_to_check = 9
|
||||
# print(f"cheker for {x} {y}")
|
||||
# print(f"roll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
while (int(roll_count) >= 4) is False or (filds_to_check <= 0) is False:
|
||||
# print(f"Предположительные координаты для range: x {list(range(x - 1,x + 2))}, y {list(range(y - 1, y +2))}")
|
||||
for n_x in list(range(x - 1, x + 2)):
|
||||
for n_y in list(range(y - 1, y + 2)):
|
||||
# print(f"Существует поле {n_x} {n_y}? {fild_exist(n_x,n_y)}")
|
||||
if fild_exist(n_x, n_y):
|
||||
if karta[n_x][n_y] != "." and not (n_x == x and n_y == y):
|
||||
roll_count += 1
|
||||
filds_to_check -= 1
|
||||
# print(f"ADD +1 to roll_count\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
elif n_x == x and n_y == y:
|
||||
# print(f"Do not self chek!!!\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
filds_to_check -= 1
|
||||
else:
|
||||
# print(f"field has a .\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
filds_to_check -= 1
|
||||
else:
|
||||
# print(f"FIeld dos'n exist\nroll_count {roll_count}\nfilds_to_check {filds_to_check}")
|
||||
filds_to_check -= 1
|
||||
# print("FINAL roll_count =",roll_count)
|
||||
# print(filds_to_check <= 0)
|
||||
# print("="*100)
|
||||
return roll_count
|
||||
|
||||
|
||||
# Основное тело
|
||||
def reducer():
|
||||
result = 0
|
||||
print("*" * (len(karta[0])), " Начало reducer")
|
||||
for row in karta:
|
||||
print("".join(row))
|
||||
for x, val_x in enumerate(karta):
|
||||
for y, val_y in enumerate(karta[x]):
|
||||
# print(f"проверяем координаты: x={x}, y={y}")
|
||||
if karta[x][y] != ".":
|
||||
if cheker(x, y) < 4:
|
||||
karta[x][y] = "x"
|
||||
result += 1
|
||||
# print(f"cheker for {x} {y} is {cheker(x,y)}")
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
print("*" * (len(karta[0])), " Конец reducer")
|
||||
for row in karta:
|
||||
print("".join(row))
|
||||
return result
|
||||
|
||||
|
||||
old_result = 0
|
||||
new_result = reducer()
|
||||
all_result = new_result
|
||||
print(f"new_result: {new_result}")
|
||||
print("-" * (len(karta[0])), "НАЧАЛО While")
|
||||
while new_result != 0:
|
||||
old_result = new_result
|
||||
for row in karta:
|
||||
for i, r in enumerate(row):
|
||||
row[i] = r.replace("x", ".")
|
||||
for row in karta:
|
||||
print("".join(row))
|
||||
print("-" * (len(karta[0])), " После замены x на .")
|
||||
|
||||
new_result = reducer()
|
||||
print(f"Remove {abs(new_result - old_result)} roll of paper\n")
|
||||
print(f"old_result: {old_result} new_result: {new_result}")
|
||||
all_result += new_result
|
||||
|
||||
|
||||
print("=" * (len(karta[0])))
|
||||
for row in karta:
|
||||
print("".join(row))
|
||||
print("Result", all_result)
|
||||
Reference in New Issue
Block a user