Compare commits
	
		
			2 Commits
		
	
	
		
			7fde412a04
			...
			383ff93502
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 383ff93502 | |||
| 9c7847b91c | 
							
								
								
									
										99
									
								
								day08/input
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								day08/input
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,99 @@
 | 
				
			|||||||
 | 
					333430420313204425152200622665264212245045167252605104200413164212660350624632202413410021112040303
 | 
				
			||||||
 | 
					134032100422510245106510040264663362503422541041505357621476703420114122465165643524253354025030130
 | 
				
			||||||
 | 
					210440124144200401002041231025015610061612057522105774716346600327132553305630102152112533024041242
 | 
				
			||||||
 | 
					013233025442442502513652024201322435500523165612141337672674773011016503513304233064521152335042120
 | 
				
			||||||
 | 
					011305252432552501064411033666722407647207507507162465046733615606446206134542053636654320003411012
 | 
				
			||||||
 | 
					243023202214501634062402146610001573103776454700372701707211030076547400104323412251550200540512404
 | 
				
			||||||
 | 
					012253133143312645661144666762653037430267574705006276313562402352550711050455115603136051241513541
 | 
				
			||||||
 | 
					233542100202100442245031231337073750307372173356368622812112644626652722416200145424010111505415531
 | 
				
			||||||
 | 
					113050445521502306510155606560425124341767678204475464563457405544476324177711546422100335421551051
 | 
				
			||||||
 | 
					130312341330642365123453250761202155236155527441423565417554884760031702032102426223145121613433104
 | 
				
			||||||
 | 
					530143503231520461205002652051677511261563711762374740277300428262470663721100666052106105145213354
 | 
				
			||||||
 | 
					151015303344663420237540025132125454561370180385741740506056160664715223770111664734064302411202001
 | 
				
			||||||
 | 
					514034244406063254635323474251671315666526663746817240033573000108656045541344434601625022610052020
 | 
				
			||||||
 | 
					243154262363253554536541354003054186654045878102055585888161073638066213274671743325026010363535544
 | 
				
			||||||
 | 
					154120103402345375743506401360683734777656123267113230466240585461121530607117743057503356131114533
 | 
				
			||||||
 | 
					505455224133247240206564160431257714250053833782497581816130354025606255867122005077143403662520504
 | 
				
			||||||
 | 
					433241563055247633235066320883447875386276657781137827895139991200185503683760166777605024035426130
 | 
				
			||||||
 | 
					303666031235074150733051862308708620362115983146857284227577913250668362434852742536154264141044024
 | 
				
			||||||
 | 
					511222166044117055516803386663311572614519912678966147915185424343732707633260441221576201346435364
 | 
				
			||||||
 | 
					134360166233105100536433310812063681167658735195196145453391339382888328188314274546107317546511612
 | 
				
			||||||
 | 
					523620025403415442506243437017113976271955932743366455248318611782168343828238367826356710005034553
 | 
				
			||||||
 | 
					014143654212533674034560645259292873615816185144293735857682321366761974620115762457417172700305122
 | 
				
			||||||
 | 
					333105652265122475614582321536546127468959745749345269543234433166487289336786316820563170617120623
 | 
				
			||||||
 | 
					121601237502476667431600852195954252478198756563435696885982284312387934896760152481177324330131535
 | 
				
			||||||
 | 
					513446344670703428776508215695735445332247985475848233554657523817331875769331074017245476757301446
 | 
				
			||||||
 | 
					012251345264710602027058214811913234262454325876757887757444777969332385321984700241201345057245460
 | 
				
			||||||
 | 
					332461240272352410086272428238633529256552789239244723226288876562681521623121465728463663000253564
 | 
				
			||||||
 | 
					050241632437771176667281335711828626835432482452477575257825295624648638453256338282617312743052665
 | 
				
			||||||
 | 
					320460534364211482024332384631858292847294377732562824355842225275426886973273352617364252451510462
 | 
				
			||||||
 | 
					266231012324356276581324273442396899956952282898875358753279379896748925691919481576682154760400425
 | 
				
			||||||
 | 
					251566121704323168579128997588889283799488966757983883789954475486796857383783125527355207013547362
 | 
				
			||||||
 | 
					245170254224671131425381468779784773763587376849883899445985425964397253171121657364305543424605521
 | 
				
			||||||
 | 
					343241363651032654076929887424957669374497498475354869687897566288757258268124776805646407142505401
 | 
				
			||||||
 | 
					245235561074546607814525522575333844748378895964779738636436493832747556344467633450422573200613626
 | 
				
			||||||
 | 
					621467001761357111428393119677926772938443995376393853338365997532477292336453235160086048160217366
 | 
				
			||||||
 | 
					023775641054213273228832376568693489696566663398748497398659859837842294529619661172107248203627734
 | 
				
			||||||
 | 
					113467643020563674853798174949656774647946468556996446468936764346927347556233294257603825510225301
 | 
				
			||||||
 | 
					051772112150067612784116555244795748964966494976764476446478663548637694355969461949802873774665326
 | 
				
			||||||
 | 
					331233366625881187249285952947585544548997559569878848947886766655686939429493965123777681254223431
 | 
				
			||||||
 | 
					531573100137313597119916274627286959837544585968649788887976885577683473432893398693858562631240775
 | 
				
			||||||
 | 
					054773273536345576254932477965348359857659449696548949674766533585646392228226613594760535225257520
 | 
				
			||||||
 | 
					634743657825387116635366754892478485999446656868585575764798688597369672379597529612611500237237137
 | 
				
			||||||
 | 
					651102700443476274786872839522556949489444557965565689748499865784355354284683261999963545702441533
 | 
				
			||||||
 | 
					410422511344877258216478752346893586694958864569678896795749775497587467528943274138345032337425341
 | 
				
			||||||
 | 
					673074304265406323296329836734538597845554475567958596678746854759768739593368885149598108068333526
 | 
				
			||||||
 | 
					164263147103304418178278924224955484489949675979877868596747956467863649963887857128138635543007456
 | 
				
			||||||
 | 
					532045787035117465515664676376447636548656879595576977999774677855856735289939791867587713667806712
 | 
				
			||||||
 | 
					140404452768874515592229468574985653794588555889757998699874747589835947525564614257120186050531145
 | 
				
			||||||
 | 
					626535737062375329774963856647668644846998677768989895657468468657744348329253697139398584012102340
 | 
				
			||||||
 | 
					542125001671358961555599377429643566889856477767859887987675655559949868728345434499546123323161001
 | 
				
			||||||
 | 
					762120151054669481822452228565333874958454877687779859759785868573886766599894442765981274505151104
 | 
				
			||||||
 | 
					562471434368683846173563223634735557586587876899579875869878986493584743886292333767594628622775172
 | 
				
			||||||
 | 
					734222626506039543828356435245676596966499685666977779895844487493883497384439766576599302272713402
 | 
				
			||||||
 | 
					267177441831802248969359922326967573465467679688596788687556889843594594235859261867187578441714647
 | 
				
			||||||
 | 
					102117327257157522217556335628537334684966957875575975895695664957459754746968515546793540724822122
 | 
				
			||||||
 | 
					505233476882555673336484437283696496447664879799897577664966999965538753757237631528664630007177613
 | 
				
			||||||
 | 
					172066031365473733492776338746459955449887594496989558546775496577455654236726314131630007341654314
 | 
				
			||||||
 | 
					314412002266354633365762544569746844798457477779477686985845846857578447499935436861745481600772033
 | 
				
			||||||
 | 
					055237658717854148961524344444377964774585475448796459485964778855656967368965165942952602115364653
 | 
				
			||||||
 | 
					101635324187220117445419465884645869853647668548567797785599767597638684836376214415920463048311165
 | 
				
			||||||
 | 
					617323525735135461172377579929749788439689969985978844695495846787466498442754416512973663308107726
 | 
				
			||||||
 | 
					530710323015385832525292779264243858439684558659447696949696563673466249277668864281263486712173314
 | 
				
			||||||
 | 
					002226007723488635329843652368236983569879555555499475484483447567969679832981393855106427002552444
 | 
				
			||||||
 | 
					235757010870250337834974492853239769846747448878894988996873977468347779876273667633884411064437311
 | 
				
			||||||
 | 
					221537334662832777621573374939367297734988578388657548445987535345422574756283382295070667547270175
 | 
				
			||||||
 | 
					521462413004381720189539712492796774975667453383769536485344786668527448878163526268353212024115651
 | 
				
			||||||
 | 
					064167050511487528145433135444328348559358573773345433397876388385483662364771941163658800310756444
 | 
				
			||||||
 | 
					436636405027304747391412742798583342975676858784346378455554898673579853526351275216574538060506774
 | 
				
			||||||
 | 
					566540130441706782811763156886277636247669397646566433399777965674843633877716691920750361127241155
 | 
				
			||||||
 | 
					053372117542772170611448311472432495277284498837535486344595366632773998492323674853732413030542046
 | 
				
			||||||
 | 
					534364447320670867339153474824374957359843939965384798895376292698497378559437674083011730747713713
 | 
				
			||||||
 | 
					216264161444177358545356854382958565667999985377695889365464464565434283664444674351070427062510112
 | 
				
			||||||
 | 
					364206763745554337574296145539342755237347237689765249424576387533835284249337951552318166532717320
 | 
				
			||||||
 | 
					301321356401273810374524947234817483255967848336723823829824987424831571693585243183871374121705463
 | 
				
			||||||
 | 
					013142075522165017716733784396332487689825356344265736822666843742955823165716761855438154413641115
 | 
				
			||||||
 | 
					630515150411425607542463652174216633554978982572463873259338392247874837335324720668014545652155202
 | 
				
			||||||
 | 
					455031465466436525813303414966445845648576498854883558298456269113968383196025720070233635412326555
 | 
				
			||||||
 | 
					513541260473273275035537870749767166583572678469583476276998677949239286734633062745335042001531221
 | 
				
			||||||
 | 
					601365053241646675287550254721413885162954529985825668299219771922524729302706116406630414253264405
 | 
				
			||||||
 | 
					400344346330307036562615004227693316398374195415562381655134627581299617653477441607644245074524600
 | 
				
			||||||
 | 
					210313442047552663082465608147628816371648823764493322559365352994178913344658255573614412766560553
 | 
				
			||||||
 | 
					111352631055464137145152202878508984883298488591213254293969862555144081556414044421631665225522264
 | 
				
			||||||
 | 
					010164431247751037435264713238223247871448917563495625643168725587551433114342107055334272403301466
 | 
				
			||||||
 | 
					525253154605640500025274247121151664615511794958191647464479638471563708865215767367622432614243221
 | 
				
			||||||
 | 
					414144456652451577051364610780083460325111586672621671575123547806751385176766676676633016126156340
 | 
				
			||||||
 | 
					403125420124660622446312308556131072702464323774759977763680287787058873788251453020274036222556015
 | 
				
			||||||
 | 
					010450420461552234703024366261462024624268728424661115870447017746132551326225623245140220643235304
 | 
				
			||||||
 | 
					331053044132010120214026102738858112181065532060281161763064277514475458526554547622102204600502333
 | 
				
			||||||
 | 
					530232021520613242257763671271000321860552177274506581315403280378427012530121320262015343211500552
 | 
				
			||||||
 | 
					513451503556626221314452431160424362623172424403733615107832160275406543265725327322555342222542502
 | 
				
			||||||
 | 
					202051420236066361423130725131562714626884368317212022283380747212427753155731701600356565400542402
 | 
				
			||||||
 | 
					435145215102611325100662266006561366705875616488262665660460450412270343501022642555052262142035502
 | 
				
			||||||
 | 
					334403454455503501622450035064441374653775177026475804121642120210207061757610262641220243402302545
 | 
				
			||||||
 | 
					321311214442661462245102175522241130532337170266155071611254164127776674570166055246211562130500431
 | 
				
			||||||
 | 
					443124503252503622414632304026653173070670661231063766052605435514223357361561150225254553205315111
 | 
				
			||||||
 | 
					232120055124304462512532500502156531032207726437333213051406414333207241265312052356525310410451511
 | 
				
			||||||
 | 
					202002311103141164630106023656017441203731706174163257322311073432575771525344436600220200050051342
 | 
				
			||||||
 | 
					041004212342412120333645230362446732233342662123535575315702023322757200126221443432142400145220443
 | 
				
			||||||
 | 
					420334452105533313552263566256611333163022717266264743363602103371464132116230560501113054442342042
 | 
				
			||||||
							
								
								
									
										1
									
								
								day08/input.ivy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								day08/input.ivy
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										5
									
								
								day08/sample
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								day08/sample
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					30373
 | 
				
			||||||
 | 
					25512
 | 
				
			||||||
 | 
					65332
 | 
				
			||||||
 | 
					33549
 | 
				
			||||||
 | 
					35390
 | 
				
			||||||
							
								
								
									
										17
									
								
								day08/sol.ivy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								day08/sol.ivy
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					) get "input.ivy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sample = 5 5 rho 3 0 3 7 3 2 5 5 1 2 6 5 3 3 2 3 3 5 4 9 3 5 3 9 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					op visible r =
 | 
				
			||||||
 | 
					    r = -1, r
 | 
				
			||||||
 | 
					    r = transp max\ transp r
 | 
				
			||||||
 | 
					    r = r > -1 flip r
 | 
				
			||||||
 | 
					    1 drop r
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					op vis2 m = (visible m) or (flip visible flip m)
 | 
				
			||||||
 | 
					op vis4 m = (vis2 m) or (transp vis2 transp m)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sample
 | 
				
			||||||
 | 
					+/, vis4 sample
 | 
				
			||||||
 | 
					+/, vis4 input
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										42
									
								
								day08/sol.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								day08/sol.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					data = []
 | 
				
			||||||
 | 
					for line in open("input"):
 | 
				
			||||||
 | 
					    data.append(list(map(int, line.strip())))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					visible = [[0]*len(x) for x in data]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for i in range(len(data)):
 | 
				
			||||||
 | 
					    h = -1
 | 
				
			||||||
 | 
					    for j in range(len(data[i])):
 | 
				
			||||||
 | 
					        if data[i][j] > h:
 | 
				
			||||||
 | 
					            visible[i][j] = 1
 | 
				
			||||||
 | 
					            h = data[i][j]
 | 
				
			||||||
 | 
					        if h == 9:
 | 
				
			||||||
 | 
					            break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    h = -1
 | 
				
			||||||
 | 
					    for j in reversed(range(len(data[i]))):
 | 
				
			||||||
 | 
					        if data[i][j] > h:
 | 
				
			||||||
 | 
					            visible[i][j] = 1
 | 
				
			||||||
 | 
					            h = data[i][j]
 | 
				
			||||||
 | 
					        if h == 9:
 | 
				
			||||||
 | 
					            break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for j in range(len(data[0])):
 | 
				
			||||||
 | 
					    h = -1
 | 
				
			||||||
 | 
					    for i in range(len(data)):
 | 
				
			||||||
 | 
					        if data[i][j] > h:
 | 
				
			||||||
 | 
					            visible[i][j] = 1
 | 
				
			||||||
 | 
					            h = data[i][j]
 | 
				
			||||||
 | 
					        if h == 9:
 | 
				
			||||||
 | 
					            break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    h = -1
 | 
				
			||||||
 | 
					    for i in reversed(range(len(data))):
 | 
				
			||||||
 | 
					        if data[i][j] > h:
 | 
				
			||||||
 | 
					            visible[i][j] = 1
 | 
				
			||||||
 | 
					            h = data[i][j]
 | 
				
			||||||
 | 
					        if h == 9:
 | 
				
			||||||
 | 
					            break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#print(visible)
 | 
				
			||||||
 | 
					print(sum(sum(x) for x in visible))
 | 
				
			||||||
							
								
								
									
										47
									
								
								day08/sol2.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								day08/sol2.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					data = []
 | 
				
			||||||
 | 
					for line in open("input"):
 | 
				
			||||||
 | 
					    data.append(list(map(int, line.strip())))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					scores = []
 | 
				
			||||||
 | 
					for ii in range(len(data)):
 | 
				
			||||||
 | 
					    for jj in range(len(data[ii])):
 | 
				
			||||||
 | 
					        top = data[ii][jj]
 | 
				
			||||||
 | 
					        h = -1
 | 
				
			||||||
 | 
					        a = 0
 | 
				
			||||||
 | 
					        for j in range(jj+1, len(data[ii])):
 | 
				
			||||||
 | 
					            a += 1
 | 
				
			||||||
 | 
					            h = data[ii][j]
 | 
				
			||||||
 | 
					            if h >= top:
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        b = 0
 | 
				
			||||||
 | 
					        h = -1
 | 
				
			||||||
 | 
					        for j in reversed(range(0, jj)):
 | 
				
			||||||
 | 
					            b += 1
 | 
				
			||||||
 | 
					            h = data[ii][j]
 | 
				
			||||||
 | 
					            if h >= top:
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        c = 0
 | 
				
			||||||
 | 
					        h = -1
 | 
				
			||||||
 | 
					        for i in range(ii+1, len(data)):
 | 
				
			||||||
 | 
					            c += 1
 | 
				
			||||||
 | 
					            h = data[i][jj]
 | 
				
			||||||
 | 
					            if h >= top:
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        d = 0
 | 
				
			||||||
 | 
					        h = -1
 | 
				
			||||||
 | 
					        for i in reversed(range(0, ii)):
 | 
				
			||||||
 | 
					            d += 1
 | 
				
			||||||
 | 
					            h = data[i][jj]
 | 
				
			||||||
 | 
					            if h >= top:
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        print(ii,jj,a,b,c,d)
 | 
				
			||||||
 | 
					        score = a*b*c*d
 | 
				
			||||||
 | 
					        scores.append(score)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#print(visible)
 | 
				
			||||||
 | 
					#print(sum(sum(x) for x in visible))
 | 
				
			||||||
 | 
					print(max(scores))
 | 
				
			||||||
							
								
								
									
										34
									
								
								day08/toivy.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								day08/toivy.py
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Converts a text file containing a list of integers
 | 
				
			||||||
 | 
					into a format that can be loaded by ivy.
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					with open("input") as f:
 | 
				
			||||||
 | 
					    lines = f.read().splitlines()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					data = []
 | 
				
			||||||
 | 
					for line in lines:
 | 
				
			||||||
 | 
					    line = list(line.strip())
 | 
				
			||||||
 | 
					    data.append(line)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def count(row):
 | 
				
			||||||
 | 
					    n = 0
 | 
				
			||||||
 | 
					    for x in row:
 | 
				
			||||||
 | 
					        if x.isdigit():
 | 
				
			||||||
 | 
					            n += 1
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            n += len(x)
 | 
				
			||||||
 | 
					    return n
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cols = max(map(count, data))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					print("input = {} {} rho".format(len(data), cols), end="")
 | 
				
			||||||
 | 
					for row in data:
 | 
				
			||||||
 | 
					    print("", " ".join(
 | 
				
			||||||
 | 
					        x if x.isdigit() else repr(x)
 | 
				
			||||||
 | 
					        for x in row), end="")
 | 
				
			||||||
 | 
					    n = count(row)
 | 
				
			||||||
 | 
					    if n < cols:
 | 
				
			||||||
 | 
					        print(" 0" * (cols - n), end="")
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user