this time with no legal info

This commit is contained in:
2025-12-08 01:11:02 +00:00
commit 2f38ac9096
29 changed files with 72807 additions and 0 deletions

BIN
1/count Executable file

Binary file not shown.

25
1/count.c Normal file
View File

@@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *file;
int count = 0;
int num = 50, add;
char rot;
file = fopen("input.txt", "r");
if (file == NULL) {
perror("Error opening file");
return 1;
}
while (fscanf(file, "%c%d\n", &rot, &add) == 2) {
num += (rot == 'R') ? add : -add;
num %= 100;
if (num < 0)
num += 100;
count += num ? 0 : 1;
}
fclose(file);
printf("Password: %d\n", count);
return 0;
}

BIN
1/count2 Executable file

Binary file not shown.

35
1/count2.c Normal file
View File

@@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *file;
int count = 0;
int num = 50, add;
char rot;
file = fopen("input.txt", "r");
if (file == NULL) {
perror("Error opening file");
return 1;
}
while (fscanf(file, " %c%d", &rot, &add) == 2) {
if (rot == 'R') {
count += (num + add) / 100;
num = (num + add) % 100;
} else if (rot == 'L') {
if (num == 0) {
count += add / 100;
} else if (add < num) {
// No wrap-around
} else {
count += ((add - num) / 100) + 1;
}
num = (num - add) % 100;
if (num < 0)
num += 100;
}
}
fclose(file);
printf("Password: %d\n", count);
return 0;
}

4487
1/input.txt Normal file

File diff suppressed because it is too large Load Diff

4487
1/inputtest.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
1/test Executable file

Binary file not shown.

7
1/test.c Normal file
View File

@@ -0,0 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("%d\n", -101 % 100);
return 0;
}

34
2/Ex1-redo.py Normal file
View File

@@ -0,0 +1,34 @@
ranQ = []
count = 0
with open("input.txt") as file:
input = file.read().strip()
ranges = input.split(",")
for ran in ranges:
start, end = ran.split("-")
if len(start) == len(end):
if len(start) % 2 == 0:
ranQ.append((int(start), int(end)))
else:
if len(start) % 2 == 0:
ranQ.append((int(start), 10**len(start)- 1))
elif len(end) % 2 == 0:
ranQ.append((10**len(start), int(end)))
for start, end in ranQ:
done = []
print(f"Processing range: {start} to {end}")
start_prefix = str(start)[:len(str(start))//2]
end_prefix = str(end)[:len(str(end))//2]
for prefix in range(int(start_prefix), int(end_prefix) + 1):
candidate = int(str(prefix) * 2)
if start <= candidate <= end and candidate not in done:
print(f"Adding: {candidate}")
count += int(candidate)
done.append(candidate)
print(count)

129
2/Ex1.java Normal file
View File

@@ -0,0 +1,129 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Ex1 {
public static void main(String[] args) {
File file = new File("input.txt");
String line = null;
long count = 0;
try (Scanner scanner = new Scanner(file)) {
while (scanner.hasNextLine()) {
line = scanner.nextLine();
}
} catch (FileNotFoundException e) {
System.err.println("File not found: " + e.getMessage());
}
String[] ranges = line.split(",");
for (String range : ranges) {
System.out.println("Processing range: " + range);
String[] bounds = range.split("-");
// Case 1: bounds same size and odd length
if (bounds[0].length() == bounds[1].length() && bounds[0].length() % 2 == 1)
continue;
// Case 2: bounds same size and even length
else if (bounds[0].length() == bounds[1].length() && bounds[0].length() % 2 == 0) {
// split each in half, iterate first half of first bound to first half of second bound as longs; get other halves too
long start = Long.parseLong(bounds[0].substring(0, bounds[0].length() / 2));
long end = Long.parseLong(bounds[1].substring(0, bounds[1].length() / 2));
long startLow = Long.parseLong(bounds[0].substring(bounds[0].length() / 2));
long endLow = Long.parseLong(bounds[1].substring(bounds[1].length() / 2));
for (long i = start; i <= end; i++) {
if (start == end) { // you little prick.
if (i >= startLow && i <= endLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else if (i == start) {
if (i >= startLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else if (i == end) {
if (i <= endLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
}
}
// Case 3: bounds different sizes
else {
// Case 3a: first odd, second even
if (bounds[0].length() % 2 == 1 && bounds[1].length() % 2 == 0) {
long startNum = (long) Math.pow(10, bounds[1].length() - 1);
long startHigh = Long.parseLong(String.valueOf(startNum).substring(0, bounds[1].length() / 2));
long endHigh = Long.parseLong(bounds[1].substring(0, bounds[1].length() / 2));
long startLow = 0;
long endLow = Long.parseLong(bounds[1].substring(bounds[1].length() / 2));
for (long i = startHigh; i <= endHigh; i++) {
if (startHigh == endHigh) {
if (i >= startLow && i <= endLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
}
else if (i == startHigh) {
if (i >= startLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else if (i == endHigh) {
if (i <= endLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
}
}
//Case 3b: first even, second odd
else if (bounds[0].length() % 2 == 0 && bounds[1].length() % 2 == 1) {
// here endnum should be highest number with same length as bound0 p.e. 1200-15000 -> endnum = 9999
long endNum = (long) Math.pow(10, bounds[1].length() - 1) - 1;
long startHigh = Long.parseLong(bounds[0].substring(0, bounds[0].length() / 2));
long endHigh = Long.parseLong(String.valueOf(endNum).substring(0, bounds[0].length() / 2));
long startLow = Long.parseLong(bounds[0].substring(bounds[0].length() / 2));
long endLow = Long.parseLong(String.valueOf(endNum).substring(bounds[0].length() / 2));
for (long i = startHigh; i <= endHigh; i++) {
if (startHigh == endHigh) {
if (i >= startLow && i <= endLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
}
else if (i == startHigh) {
if (i >= startLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else if (i == endHigh) {
if (i <= endLow) {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
} else {
System.out.println("Adding: " + String.valueOf(i) + String.valueOf(i));
count += Long.parseLong(String.valueOf(i) + String.valueOf(i));
}
}
}
}
}
System.out.println("Count: " + count);
}
}

37
2/Ex2.py Normal file
View File

@@ -0,0 +1,37 @@
ranQ = []
count = 0
with open("input.txt") as file:
input = file.read().strip()
ranges = input.split(",")
for ran in ranges:
start, end = ran.split("-")
if len(start) == len(end):
ranQ.append((int(start), int(end)))
else:
if len(start) == 1:
ranQ.append((10, int(end)))
else:
ranQ.append((int(start), 10**len(start)- 1))
ranQ.append((10**len(start), int(end)))
for start, end in ranQ:
done = []
print(f"Processing range: {start} to {end}")
for i in range(1, len(str(start)) // 2 + 1):
if len(str(start)) % i != 0:
continue
start_prefix = str(start)[:i]
end_prefix = str(end)[:i]
num_repeats = len(str(start)) // i
for prefix in range(int(start_prefix), int(end_prefix) + 1):
candidate = int(str(prefix) * num_repeats)
if start <= candidate <= end and candidate not in done:
print(f"Adding: {candidate}")
count += int(candidate)
done.append(candidate)
print(count)

1
2/input.txt Normal file
View File

@@ -0,0 +1 @@
1061119-1154492,3-23,5180469-5306947,21571-38630,1054-2693,141-277,2818561476-2818661701,21177468-21246892,40-114,782642-950030,376322779-376410708,9936250-10074071,761705028-761825622,77648376-77727819,2954-10213,49589608-49781516,9797966713-9797988709,4353854-4515174,3794829-3861584,7709002-7854055,7877419320-7877566799,953065-1022091,104188-122245,25-39,125490-144195,931903328-931946237,341512-578341,262197-334859,39518-96428,653264-676258,304-842,167882-252124,11748-19561

27
3/do1.py Normal file
View File

@@ -0,0 +1,27 @@
count = 0
with open("input.txt", "r") as file:
for line in file:
largest1 = 0
largest2 = 0
lindex = 0
print(f"round 1 for line: {line.strip()}")
for i in range(len(line.strip()) - 1):
print(f"Comparing {line[i]} and {largest1}")
if int(line[i]) > largest1:
print(f"New largest found: {line[i]} at index {i}")
largest1 = int(line[i])
lindex = i
count += largest1 * 10
print(f"Largest after round 1: {largest1} at index {lindex}")
print(f"round 2 for line: {line.strip()}")
for i in range(lindex + 1, len(line.strip())):
print(f"Comparing {line[i]} and {largest2}")
if int(line[i]) > largest2:
largest2 = int(line[i])
print(f"Largest after round 2: {largest1 * 10} + {largest2}")
count += largest2
print(count)

21
3/do2.py Normal file
View File

@@ -0,0 +1,21 @@
count = 0
with open("input.txt", "r") as file:
for line in file:
largest = [0] * 12
index = 0
print(f"Processing line: {line.strip()}")
for i in range(12):
for j in range(index, len(line.strip()) - 11 + i):
print(f"Comparing {line[j]} and {largest[i]}")
if int(line[j]) > largest[i]:
print(f"New largest found: {line[j]} at index {j} for position {i}")
largest[i] = int(line[j])
index = j + 1
for i, val in enumerate(largest):
print(f"Largest at position {i}: {val}")
count += val * (10 ** (11 - i))
print(count)

200
3/input.txt Normal file
View File

@@ -0,0 +1,200 @@
3243342952212532333831142251933144323222213232122222323333226253325232222324622352337352222123223314
3353443623344444442533323673445444565758516456445436445644454644454566344444733444643563445546444734
4544644463574842545428466934446366933968639333234477948644946619455756539631276986475444645465433321
5122327242335622223222555422232732251315442341373221283825224222546743266216244223535433521222225915
4323232342322325345234234332631432121332323337324232343442422224344324423293233233323233452312432433
4872493454583666466657687369628966455649545813595473734576687664495785675633876663486248448865446343
7262312253414524453322432322224323221342622433127321333272223322233246332223233524372325213234733225
3543323353424523331332322442334221216342522452442322233372321523131243622323832333233525723222123233
4343232333332233334242633436632423374433334531212123372334433214333433333443642323125374533383364343
2412145285934415562531335123751222243462522222134222241232536263343432825362223362321631232522132242
2864811433432334472224242423433454414633234228246252548637584358332233712425432736526542479564748392
1331233334322132333333438332332333633342332313332624343433633323833323333332313434323243322342323333
4222222122231422313212223214142212252222222122223213121325212223312223252232132124211232221422112722
3597464736467757425647554555736547566357467448657553773674456566766467545675764775544554546664596663
4334222222222232222433333323322221342121222334212632422343432231212283211233342343313323254233223233
5435643441664733426365743225253246533243626385234676562563339366555542654312256634296433546672424453
4255235342132644234212221762524355311424353644342225453232353325233225423233652335212235422223222512
2212222322523222132222232222222122322221222222212212522222112222221222121223131232223322223223221221
9344745395656528759446474762443744278376528888828482673645384685666773577547695964287348363336794598
3224423232444325634115622541322256543424366243244245474255324342245426444663344365422512455743446623
3223454436253472352424144242543693124234523332434343422414143443334381444474445623442944334434424563
3433744345944353536244226444237577546434343424657485537436546472457337466637234554565863456743837654
5426333333323422243322331622321232531412323224327255625621243323242232267422232865363224333123625323
3622373343246355422245134456645162233454222244422332242645536552542645325235423334532222253136422232
3134332222332123434323323321123222333122222232332233333112435323322333223123212332322331332223222342
1242362435348113325228512323126435245255332152242733226259322255221324224364532215262252535127225622
1121382322522243343154224122222252221114422222221242422222123321224421123222122512234214224722322513
2313223323452232443335535333233474413345342242333533333142443321663321323333133423142332323234222322
5454396555445776447347564845545354544955545533775546555445563546545555644945455555455516575554474545
4658453654546429446265443454655643665684533326474388744367574863484463443545354466844464723945548437
4544447462844657154551314548755445222775423333322755737574477382635442333553554254554675554554485835
8464357246935655445644345343634255424446534444454146444573445424432521452444145434755445615435844454
2232323333342236213211342521322233223311326232142332622212222223233233432632323321323126121222233322
5223333343153323312332473223323144432323453134414243122153922232542334244322144223245523134264424222
3333129524232222232341222232322227122242222232222252332222242321224321222243412421236121222333223222
6754556372372554522223323343313425324242222334453433343347235232522514533445427257295422225927728643
4433332143428342723444225122628424422224255264122444534282531322432254343442325365464522454674432523
2494312179242323172344832733132253651522434323244423229423228512264623394451222345233121522664522222
6323362463156443426754634637423234464363525462626325446454535333734546664444374741546346257444353362
2242211324423247231122222521312253232222232215412255322242222511132222324232222235221222134312142612
3422233334433433332324373343223343444343233333433414343442333542442433313343433322338213443333434334
2222121122123252522212322222222252222222224211322142212222322111211223221322221222224112124212721231
6646665675266656566534442566663653466664355324635566564464436636663667544265655554436642456534353655
2224122246246152255426222222613234136435252325241112452521273222344212312231212444123221212225222412
3672222262533221222222442515412522242222232223152412122242344222225622263222214224163312726322422222
2423672593736712554339283535832492567579324354338268236223433393778593339723332394976743369464556353
1244343452133334322235334241213242538232324143125232142451222322231323328332325453423233331112233232
3122122212222222332222222323421221211222222213212222223212211223233232322212233132232215222221212221
5865825462652524644434554377636576582336724652613587463252545575373434578425565867245342444757436361
1512122422532252321122212221223221522212322132332322324322233232233233222333526222223123231222231223
2433333221336335626417722221334773353133434213523636623323362333332533333222553322122131123223356134
7535512233234222333232353222133565335313335233334445114732332232212232534543133342214733133315243133
4324224122452323663233332342653627233546363232432656322554344213425432143433233433334132441642335233
4343323484235574214315233273462235423532554443514736255554343911242442244565644343474623723459375423
3222923113352342232152362425312293222442231223234232222322223218922221225221221132212228246252226372
2334832222443323252224132142333422121323323433222224232826412133242632245221522121662323223222222241
2222331242222512212222221221222121222422222222222212222211221314242222222112423241332262127342252262
2415262622552255346264636433113423231323633743156212256384534441621143725246332523454323223424542956
3225313333535542223237541543332343543154547323545554453372164513335425445364333635334157235444346463
1217216222221322233311242311242212222224212621442212233212247222132422222212223132222222233222125214
2243622334444222242152422424229222421231352121214244312222234412425422241322222522322232432341212222
2343654345533333332343454334232423334361147223736227254223443322237311633334355234243442232345433434
2425533328234421351492127693223222212321842334252545223233423223228211422372534422646272324325316244
3333393233322333323322233322113332334522342323332363311444224235353323242422235235225343232321335344
2333323334353213133922344322332323121234324333333333333323324423333222213333321233225332333332344323
3344423431313423333133232232423241352344433243234324241313313421135213433422313412322231332324442343
2374223331325122223233122231222332423422128311233322242222213222152523233222166222323663312223222122
3224213234834524512322323224232732262133522443242731223222322211331122222332332213122212214224821214
3446325684543686527771818352554478526563585272267631871518232252667243861482371354346615272735662829
2443447233351223453231122524343242524275344732433355633421324333422564344243452435415353443244344247
4313325255323233431122455355521342914244554444244153344443923434353353472122254435344414341563435433
2443313413233344323344353344334233232534343423143633433436433342443443332334333243422334243342433442
2233332122216333212225143333333352453333233333324632341325336233122363333333223342233333332322145312
3333232346233623233333644333343633334532433512323333323332443546231133632333363271133425321133323133
4444374343434434244544345444347521344543434443244444244443434344245353334344444734638349383534444244
5846694454745176466483363334858365854345446448443263376255414651534687843624444463157453115474447655
7355221344424533425345345445463336453535455456725234244443235425544233441433353335313124344346343355
6755476626574656663763466674465672657556895357156544567547566563776547659517754439367166345594473585
4424224242341222233362122432426122223272246522623233133533224553434322356431232243352753522543246424
2343487322374225873675273229553263314234254347245137662221243823345342582524572925737766423355426228
3295232254123543554248323362512386442313333341253325434132525633532435424323534325313333532222323336
5712225545123233125642322342224454222224645125523323615263312227513524572513425221254532342253325537
6463546269253474666364577551333675352336643746264343454544333548672562815537375526516854525142757661
4358424667685444465547558466556446924444845445795664647754445335458554544554444443644553645555335486
3211122433412434124343132222241222412414141313112233431211422134111232142222232233211211111223256789
4432253836322534474773467627624474454444437825447427442345431554472263475446664473167662516372434437
2222253423222222422222234142325285225222121223112244232245227221222211212123322212221212222213322222
1334333132333525463365522322332333534333332322242233323221335233432323273123226323254434222352225332
2222121222251213222122121222215322222224412321222252223222224372224232222112222242224224321522124222
3323423843355435332354434436475345472842233647637434363412533332847334444463553443746334637657443334
4151154413234535222543154221222523545441214542112132122151232313544115214432311332121424534543226789
3233721352132231326323332122232332132411542334221322232212321242222727213823323323323633323322257522
3623425223321433353533333227233463343532235383232234342324279231233232745132115251233331335343363332
2225631325232222331132223242631222523232612243122542212722344132222222332422212227242262221252223222
4245141234538445442315532243236354226222255243655442435523233433352326533525453516455252344556254453
5223524523221422122255224152222222212322243233123224121322224213222229222212232143622322335224122222
3324124145315152534142323441353223433345442472354334225433265322353255433535242512334535354453514445
2224222322122222322212323222322212212213227223222432223211213222223223423112343222226232222212222233
2223222221231124214322222343432622212221222211112212321221211212322245221242423322222322422252424342
1112422113343622632322123123323623223337212334133125433312323621252227121252123122243212142222125332
4435425334341425648453435333333444537394454335433453424242343344442464954254531632344332653464444341
5853344266446552325362233536633133324333663253323384423942661424233613342346284563345363435343336642
7654476357344448773453835623571233542247352543541453461334334383474455342384364345434336474668333333
2433123335256417183232642625574474447745672724772623432235622635482473464611573746254422244215253238
4544634574533356639436356296494443535453466653766435464894666549444674547258624265765575545764585492
4244433443243396375483342354444342414344393493444644494248334444467644443344335454424449863345358643
7588396364755748744334565764413567477586673523446885544538764844444886886732424786567827746476678773
2225312224332111224221122422214223223822215422331442322222251426321242455126342324232114342422122212
6477647577377357764529147427567376355446425664556575745365496575654237767763255674765557673712665156
4843646486774657873455344743645364473375874449457543534453475454547383326246636344446593767673645493
5546325544544433354343245322488535443555433235546748452344584865331745234375525554353266339434534552
6569458535458577718836655584635645955357445443775756694475565345447777935755495567485453566645575555
2225422722412224751512442372233222233243323223152442211311233261233242363312321232231622342223433535
3122232221222342241213233244322232241243222212233222312222223213143222222232422323312422213223312324
2743399462563317465862234644563444357852568235448645465844363747876465434346598649558353668555535745
7527743356761115771527465546477427767227443322635624473412672215476744364313312165216412751634172189
3343363343332443733342433433234433373488616233283313232333333323133333333273622233337373342353333343
1228229312222432643222422422221235426324334324334142853321241234432224222244422242353243472322332915
1322113222232341222134524232222222222324312121222122222212222257222233222532222222242541222232222232
5233325442237122332324223222227235244421233222354223432218234425848222435432121122221245153274216721
2434833868385432466424354653334522635836132479474618334173421163238335244392425446458879434656528522
5323543533433434222243473383352535335333435455833554365332333535343543333333535351443335352454533533
3222212324232122353322224245252242524222323322222222133334321124222112214232222325312523359222225322
1117435224226142737923212423122422123342212132222323223223422343263345346224341423212442613223332212
3643434343444424424232134434323524164335345424444431424267424237314364364244442538244423334175644244
3633246453443332124424643374334334434464432444443143227423422644343234354437464443413344383474334244
3556558432556333478555334846432431464251566468456845586852657365943267553746367157543532735852716546
5522234323355224252322251342252254323324113252125232545543543243612413224342333334254552331423423324
6554954444464539478638739656534448665476564455954532175579756359346743166689833568488374854856975532
2482467639573357674464357445667845613676464635723653645754635553427468728347557324676675665737444667
6655795545471353366652252545335442533235643333383565653233325353243543654643636552263524364456357535
4354645554445533446445461443434525453234425244566532243857434453523424543448451544333422533231243353
2243242222222343722242423327313412135246224243322282322123422212112722224223532347122223413134831224
3323231224426343212222333333335232252123322132231232242222332232212221333232123152232123314153333112
2812524241232222676666461464416426163822386448712326523472247225327142784222685254258253124724167521
3362321132334542342232222532254124232316234223112221222344223123243222534413232442232323234324322242
5353535535447365524531553464573355535424453557445345735255454545354451355444551535675555538354545454
2282212222222324224221111212212211223121522222112221222322332223222322162322222122332232138221222232
1124222422311342132113414222222243222215112312212922145252322352522224924222322312222622342224212222
5426554244452442246645554544444324442446242424444446556626464343413552344241355345444554586354545454
4424424243233243432362434444322335335333345433124344413133433439415333443443433424444312233334424234
4335342342233331534523235422433247334322343333423331424313312344423334234333342533334354332312143434
3754968746847553256575435394354443553443364634585435285772344552492454544143352364822369715655463365
2342333313632313122233333234342243323343232233432334232314233323332123414223321322332373334234142323
2523652332232424522232123542452222324233112122234252524121352512323212546122422532232143523452222233
2531623222132337525364243355336536334636323326332353433243354216463332222262223833152312236522156925
3423233733463143323394255333752433434231523233333365333124766633332343542633343333473333334344863333
3533243333324255553533532235433738259315537534353523543375523431332323225245314442135533333333332234
4454333334534433343434343211335344434433334123331343374444373333433331332444223323437336444332433242
4373233633333339233223323272333333333433333333333333333442334333733433332333332323363233333234333332
2222123222242232222424522222241222221222223531223213512222323212113213321411142142222422112223272212
5655254624457577376632776658635557236275677343167556857353336457553432473666327443433172937694454398
3343221435333642524355413734133233313342224324353137243452333233242615333233723853654432384334528282
1344534125256233212223254232835324614232335393313326645432695582522333233361222233262555533622513542
4242231523342252582426776253242522424783223422829264632632453333123525327122231522635622324763422235
2154243564444445214243555446463452464444122326426465644665531443463333437352153354439243317134434232
2432352843523214655335423222632333323324642232623564325364522384332325331346623734238553633613623621
4325344333255553555655585424426214465344546643537355357413263546158614525343645543554135245528444456
3443463525644443433432263354212321411534838628522233231293434222445424144432129941722452225244222358
3243144245522344524327457532455445453434354528475332437287445363245364333534839344462625376638332372
5233233222353233823313353344422333463335235732153333421422351336333331353333733221334233423333332313
6213252222222221224221622422222822322223222121221123132232324113452622141211922222222823212428232222
2222322422312215212122731312714321424224233433226324249222632422232422613335722242282342253517321111
3336567632421356326255824343244453745352333635566558752523475477551261474619454553575455534444456346
3831446655231642232122235224422224133328222221296324271222422222242212422225424213221222123312222223
2232322222532222222223324245222222321326222122223432322222223233212222213222221324522321233223121113
1346614453165762863222372324236351261545653423656124732345375213355256445216252434672432644124666225
3553644535434344356533545446544453464441625533525455253564566444435447355645444544445467466536443586
6536234454684563574844652254253844836254414564565325437364242524573523452663635634254547647783433436
2223234225221222142222341222232221221363224322223222321222223232221332522223151222132222222132212322
2122224222222225324321312327253232312332732133115323212252223532331132223332362122222126214222422242
5867565339867736556338655683877876636557523534565335368324354664348584578276663383333466324782634574
4445664333343526338548644363344445543164755477543844841933331545578846374637763457632573546917243328
4331548313525353235364214443342454544433635315263322635353333146433444555526344424458522453644546254
4334553144154334644441123233435112331363343674333443343443262533322614533224443245336333433444626234
4372442222453314951342645554474521342254344364622443432327226444652523522953252434342443844324667322
6353347443433286737337268366534254682445656137364644647586634333453749273338534342348335356654433547
4335332333423332233343435333133363336212233433343333333633333333333233514333333323223323333333222334
2212222422332114212222223222222222223154223241221212414231322124232232222422228233222252222322422522
4533534544432344494224523154431321334323333324119535142526323453432434314425542553343332346233425235
3267436143336187224525162365256224726618232311235336168223372253456226563256922513335363966488538263
2121212234212212122332212221715123221223222231222623223332212222222222212221222221262432213235222113
5932234455324444344255155254323545235325242551325233423552355468555552334223554554552423453414434445
7345367668464745346554634726444484826838565466435838266665525535335135557465734545563587534375365547
7634482867626734874643773879945743338382678256379395597655473653154775765465744835765537386552275787
6446474755248776658565839565789474845643547289685584434428855894754888895585465497298644785284345799
7742313144324434444544524232322234532434443243244342645322863444132245314622434444444273242343422443
3114762242244746273232326244162235336434126254468223274442434344272223322535292574312324516444624261
3447435563254434725735445544537355335542253446435754544433345443343364442344343747334273644456634234
5655366666657858634756466747694666666677575666656568497665665355564266666766465564666656635436456666
7212641526136323543321423642642222552271266553333322345139223352334313333275532952332433362374424233
8529622449734236374645747753463382252992252612798415287246649464222537876876273562225352827946942515
2442233343534331242544424334331541342324233431122254344342342324441332242244424453342243423323434411
2624532412325434646616626132334555542433422511263244614316563115152666246122151346535115446335464789
2232434343243332443333432413434332214742313331354433342445374324525424243313315522375433447444344325
4563722636652515521631327222524422246555832453222644256353865523543523264633445537355355611452542336
4722554565532634217569382635464746646645973363542643674126563646256336644654634254535655642147676684
6243633632433518434434466732224545423224435333421633544243313334242363432423335432343524533135632335
3215335632333332312222322242322321333262232523332122343334323342525332334253421262212364422132322124
5555645555556232356365365454554363546565564543655535456554645645455463465445435553644446443555555746

61566
3/log Normal file

File diff suppressed because it is too large Load Diff

35
4/ex1.py Normal file
View File

@@ -0,0 +1,35 @@
import numpy as np
count = 0
rolls = np.array([])
with open('input.txt', 'r') as file:
cols_num = len(file.readline().strip())
file.seek(0)
lines_num = 0
for line in file:
for char in line.strip():
if char == '@':
rolls = np.append(rolls, 1)
else:
rolls = np.append(rolls, 0)
lines_num += 1
rolls = rolls.reshape((lines_num, cols_num))
for i in range(lines_num):
for j in range(cols_num):
if rolls[i][j] == 1:
adj_count = 0
for di in [-1, 0, 1]:
for dj in [-1, 0, 1]:
if di == 0 and dj == 0:
continue
ni, nj = i + di, j + dj
if 0 <= ni < lines_num and 0 <= nj < cols_num:
adj_count += rolls[ni][nj]
if adj_count < 4:
count += 1
print(count)

53
4/ex2.py Normal file
View File

@@ -0,0 +1,53 @@
import numpy as np
count = 0
rolls = np.array([])
#
# I would like to thoroughly apologize for this monstrosity.
# I impore you, do not let this define your opinion of me.
# But I will understand if it does.
# Thank you for your attention in this matter.
#
with open('input.txt', 'r') as file:
cols_num = len(file.readline().strip())
file.seek(0)
lines_num = 0
for line in file:
for char in line.strip():
if char == '@':
rolls = np.append(rolls, 1)
else:
rolls = np.append(rolls, 0)
lines_num += 1
rolls = rolls.reshape((lines_num, cols_num))
pass_count = -1
while pass_count != 0:
pass_count = 0
for i in range(lines_num):
for j in range(cols_num):
if rolls[i][j] == 1:
adj_count = 0
for di in [-1, 0, 1]:
for dj in [-1, 0, 1]:
if di == 0 and dj == 0:
continue
ni, nj = i + di, j + dj
if 0 <= ni < lines_num and 0 <= nj < cols_num:
if rolls[ni][nj] != 0:
adj_count += 1
if adj_count < 4:
count += 1
pass_count += 1
rolls[i][j] = 2
for i in range(lines_num):
for j in range(cols_num):
if rolls[i][j] == 2:
rolls[i][j] = 0
print(count)

140
4/input.txt Normal file
View File

@@ -0,0 +1,140 @@
@@@..@@.@@.@.@@@.@@@...@@@@@@.@@@@@@.@@@@.@..@@@.@@.@@@..@@@@.@@..@@@@@..@@@.@@@.@.@...@@@..@.@@@.@.@..@@@.@@.@.@.@@..@@@@@...@.@@@.@@@@.@@.
@@.@.@@@@@@@@.@@@.@@@@.@@@@@.@@@@@@@@..@..@@@@...@@@@@.@.@.@@@@.@@@@@@@@@.@..@.@.@@.@@@.@.@.@@@@@@@@@@@@.@@.@@.@.@@@.@@@..@.@@@@@.@..@.@@@.@
@@@@@@@@.@.@@@..@@@.@@.@@@@.@@..@.@.@@@@@@@@@@@@..@..@.@@@@@@.@.@@@@@@@@@.@.@@@@@.@@.@...@.@@@@.@@@@@@@.@@@@@@@@@..@.@.@@@@..@.@@@.@..@.@.@@
@...@@@@.@@.@..@...@.@@@@@@@.@.@.@...@@@@@.@.@@@.....@.@@.@.@@.@.@@@.@.@.@@@@@@@..@@..@.@@@@.@@@@.@@...@@@@@...@@.@@@@@@@@..@.@.@@.@@@@@@@@.
@@.@....@@.@@@.@....@@@@@@@@@@.@..@@@@.@@@@.....@..@@.@@@@@@@@@.@.@.@@@@@.@.@.@..@..@@@.@@.@@@@@@.@@.@@@.@.@..@.@.@@@.@.@.@@@@@.@@.@.@@@....
@.@.@@@@@@@@@@@@@....@.@.@@.@@.@@@@..@.@@@@@@@@@@@.@@@@@@@@@@@@@.@.@@@@..@.@@@@..@@@@..@@@@...@@@@@@.@.@@.@@@@..@.@@.@.@.@...@@....@@@@@@@@@
..@@@@.@@@.@.@@@@@@@@@@@.@@@@@@.@.@@@@@@@..@.@@@@@@@.@@@@@.@@@@@.@.@@@@@.@.@@@@@@@@.@@@@@@.@@..@@@.@@..@..@@.@.@.@@@.@@..@@@@@@.@..@.@@@.@..
@.@...@@@.@@...@.@@@.@@..@@@@@@..@@@@..@@.@@.@@@@@...@.@@@@.@@.@@@@@.@.@....@.@@.@@.@@@@@.@..@@@@@@@..@@.@.@@@@.@@.@@.@@@@@@@..@@@@.@@@..@@.
@@.@.@@@@@.@@@@.@.@@@@@@@.@.@@@@@@@@.@.@@@@@@@...@.@.@@@.@@@@@@@.@.@@@@..@@@.@...@@@@@.@@@..@@@@.@@@@@@.@@@.@..@.@@.@@@@@.@...@@@@....@@@.@.
@@@.@@@.@@..@@.@@@@@@.@@.@.@@@@@..@@@..@@@@@@@@@@@..@@@@.@@@...@@@@@@.@@.@.@.@.@@@..@.@@@.@@@.@@.......@.@@@..@@@@.@@@@@..@.@@@.@@@@@@.@@@@@
@...@@.@@@@@@..@@@@@@@@@@@...@.@.@.@@@@@@.@.@@@@..@..@@@..@@@@@@.@@..@...@.@@@@@@@@@@@@..@.@@.@.@@.@@@..@..@..@.@.@@@@@@@@@@.@@@.@@@.@@@@@@@
@.@@..@@.@@@.@@@@@@@@@....@@.@.@@@@.@@..@@.@@.@@@.@@@@.@@@@@..@.@.@@@..@.@@@.@@@@@.@@@..@@..@.@@@@@@..@.@@@.@@@..@@.@.@.@@..@@@@@@@.@@@@.@.@
@@..@.@@@.@@@...@@@@@@@@@..@@@@@@@.@@.@@.@.@@@@@...@@..@@@@.@.@@.@@@@.@.@@@.@.@.@@.@@@@.@..@.@@@@..@.@@@.@@@..@@@@.@@@@.@@@@@@@@...@@@@@@@@@
.@@@@...@@@@@.@.@.@@@@.@.@@.@@@@@@@@@@@@@@@@@.@@@.@@@@@@.@@@.@@.@@@@@@@@.@.@@.@@@@.@@@@@@@.@@@.@@@@@@@@@@..@@@.@.@.@@.@@@@@@@@@@.@@...@@@@.@
@@@@@@.@@@@@..@...@@@.@@.@@.@...@.@@..@.@@.@@@.@@@@@@.@.@@...@@@..@.@.@@@@@..@@@.@@.@.@@@@.@.@@@..@..@..@@.@@.@@@.@..@.@@..@@.@..@@@@.@@@.@.
@@@@@@@@..@@@@@@@.@@@.@@@@@@@..@@@@..@@@@@@@@@@@@..@.@@.@@@..@@@@@@.@.@@@@@.@@@...@...@@@@@.@@@..@.@@@.@@@@@@.@.@@.@.@@@..@.@.@..@.@@@...@.@
@@@@..@@...@@..@@@@@...@@.@@@@@.@@@@@.@@@@@.@@.@@@.@.@.@.@@@@.@@@@@@..@@@.@@..@@..@@.@.@.@.@@...@.@@@@@@...@..@@...@@@.@.@@@..@.@@@.@..@@.@@
@...@.@@@..@@@.@..@@.@@.@.@@@@@@@@@@@@.@.....@.@..@@.@.....@...@@@..@....@@@@@.@@@@..@.@@@.@..@@@@@@@..@.@@.@@@.@@.@@@@@@.@..@@..@@@@@@@@@@@
...@.@@.@.@@.@@@@@.@@@@@@..@@@@..@.@.@@@.@@.@@@@.@@@..@.@@@@.@@.@.@@.@@.@.@@@@@@..@@.@@@@@@@.@@.@@@.@.@@...@.@@.@@...@.@@@@.@@@@@@...@@.@@@@
@@..@@@...@.@@.......@@...@@@.@.@@.@.@@@@@.@@.@@@@@..@@@.@@@@@@@@.@@@@@@@....@.@@.@@@@.@@@.@@@@@@@@@@@@@@@.@.@@@..@..@@@@.@@.@..@@@.@@@.@.@.
..@..@@@.@.@@.@..@@@@@@..@.@@...@@.@@.@.@@.@@@@@@@..@@..@..@@@@@..@.@..@@..@@@@@@@@.@@@.@@@@@@@@.@@@@@@@.@@@@.@.@@@@@.@.@@@@@..@@@@.@.@@@@@@
.@@@@@@@@@.@.@.@..@@@.@@.@@@.@@@@@@@...@@@.@@@@@.@.@@@@@@..@@.@..@.@@@@.@@@@@@.@@....@@.@..@..@@@@@@..@@@.@@@..@@.@.@@@@.@@...@@.@@@.@@@@.@@
@@@.@.@@@@..@....@@.@.....@@@.@.@@.@@@@@.@.@.@@.@@@.@@@..@@@@@@..@@@@..@.@.@@@.@@@@@@@@@.@@@@@.@@@@@..@@@@@@@@@@..@.@.@.@@@@@@@.@@.@@.@.@.@@
@@@@@@.@@@@.@@@@@@@@@...@@@@..@@@@@.@@@.@@..@@@.@@@.@@.@@@@..@.@@@@@@.@@.@@..@.@..@...@@..@@@.@...@@.@@.@@@.@.@.@@@@@@@@....@@.@.@@@@@@@@@.@
@.@@@...@.@@@@.@..@....@@@@.@@@@.@@@@..@@@...@.@.@@@@@..@@..@..@.@@..@.@@@@@.@.@@...@@@@.@@@@@@@@@@@@@.@@@@.@.@@@@.@@@@.@@..@@@..@@@@.@@@.@.
....@@@.@@@@@@.@@.@.@@....@@.@...@..@@@@@.@@@.@@.@@@@..@@@@@.@@@.@@@.@.@.@..@@@@.@@@@@@.@...@..@.@@@@..@.@@@@.@@.@.@@..@....@.@@@@...@@@...@
.@@@@@@..@...@@@@.@@@.@.@@@..@.@@@@.@@@.@@@..@....@@@@@@.@@......@.@@...@@@@@@.@..@@@@@.@@@@.@..@@@.@@.@.@@@@.@@.@@@@@@@@.@...@@@@@@@.@@...@
..@@@@@.@@@@@@@@@.@@@@@...@.@@@@.@@@@@.....@@@@..@@@@.@@@@@@@@@.@.@....@@..@@@@@@..@@..@@@.@@@@.@@@..@..@@.@.@.@.@....@@@@.@@@.@@.@.@..@@..@
@@@@@@@@@@..@@@.@....@.@@.@@..@@@.@@.@@@@@.@..@@@..@@@.@@....@@@@@.@@..@@.@.@.@@@.@..@@@@..@@@@@.@@@@@@@@@@@@.@@.@@.@@@@.@@@.@@@@@@..@....@@
@@@@@@..@.@@@@@@@@..@@.@.@.@@@@.@@@.@@@@@@.@@@@@@@@@@@.@@@@@.@.@@.@@@@..@.@@@.@@..@..@@.@.@@....@....@.@@.@@@@@@@@.@.@.@.@.@@@...@.@@..@@@.@
.@@@@@@.@.@..@@@@@.@@@@@@@@@.@..@.@.@@@.@.@@@@....@@@@@@@..@.@..@@@.@@..@@.@.@@@@@@@@.@@@@.@.@@@...@.@@@@@@@@.@.@@@.@.@@@.@.@@@..@@@@@.@@@.@
@.@@.@.@@..@.@@@...@@@@@.@@@@@@@@@@@@.@@@@@@@.@@.@.@@@@@@.@@@...@@..@@.@@@@@@.@..@@@@@.....@@.@@@.@@..@@@.@.@..@@@.@@@@@@@@.@.@...@.@.@@@@@@
@.@@@@...@..@@.@.@@.@.@@....@@@@@@@@@@@@@..@.@@@@.@@@@@@@.@@@@@.@...@@.@@@..@@@@@@@.@..@@@@@.@@....@@@@@@@@@.@@.@@@@@..@.@@.@@@@..@....@@@@.
@@@@.@@@.@.@..@@@@@@.@@.....@@...@@@@@@...@.@@..@@@@..@.@@.@@.@.@@..@@.@@@@@@@.@@@.@@@.....@..@.@.@@@@.@.@@.@@@.@...@@@@@@@@@@@.@@.@@.@@@@@@
@.@@@@@...@@@@@@...@@@.@@@.@..@@@@...@@@@@.@@@@@.@..@...@.@@@.@.@@@.@@@@..@@@..@@@@.@...@.@@@.@@@..@@@..@@.@@@@..@@@@@@@.@.@@@@....@..@..@@@
@@@.@.@@@@@.@.@...@@@.@@.@.....@@.@@.@@@@@..@@@.@@@.....@@@@@@@@@@@@..@@@@@@..@@.@@@@@.@@@@..@.@@@.@@@@@@...@@.@@@@.@@..@..@.@.@@.@@@@.@.@@.
@@@.@.@@@@.@..@@..@.@.@@@.@.@@@@.@.@...@@.....@@@@@@@.@.@.@.@@.@@@@@@@@@@.@@.@@.@@@@@@@@@@@.@@@.@@.@@@@@@@@.@@@@@@.@.@@@@.@.@..@@@.@@@..@..@
@@.@.@.@@@@.@@@.@@@@@@@@..@@@@@.@@@@@@@..@@@.....@@@.@@.@.@.@..@.@@.@@@@.@.@@@.@@..@@.@.@@.@@.@..@@@.@@@@....@.@@@@@.@@@@@@@@@@.@.@..@@@@@@.
...@@@.@@@@.@@@@@@..@@@@..@.@..@.@.@..@.@.@@@.@@@@..@@@.@.@@@@.@.@@.@@@@@.@@@@@.@.@.@.@@@@@@.@@@.@@.@@@..@@@@@@@@...@.@@@@@.@.@@@@@..@@@@..@
.@..@...@.@@..@@.@.@@.@.@..@.@@@@.@.@@@.@@@@..@..@.@.@.@@@.@.@.@.@.@@@@@@.@.@@.@@@.@@@@@@@....@@@@@.@@@@@..@@@@.@@@.@@@.@.@...@@..@.@@@@@..@
@@@@.@@...@.@@@@..@@@@@.@@@..@.@.@@@..@@@@@@.@@@@@.@@@@.@..@@@@..@@@@@@@@@@.@@@.@.@@@.@@.@.@@@@@.@.@...@@.@...@@@.@@...@@@@@.@@@@@@.@.@.@.@@
.@.@@@.@@@@@@@.@@@.@@@@@.@@@.@@.@....@@@..@@@@@.@@..@.@@@@@@@...@@@@@.@....@.@..@@.@@@@...@.@.@..@.@@@@@@.@.@@@.@..@.@@...@@@@.@.@..@@..@@@@
@@.@@.@@@@@@.@.@@@.@@@@@@@..@@@@@@@.@@.@@..@@@.@@@@@@@@@@@..@@@@.@@@@@.@@@@@.@@.@...@@@@@.@@@@.@@@@@...@@@@@...@@@@.@@@@.@@@@@@@@@@@.@@@@@@@
.@.@@.@.@@@.@@...@.....@@@@.@@@.@@.@@@@@@.@.@.@..@@@@@..@.@@@@..@@.@@@@@@.@@@.@.@.@@@.@.@@@@@.@@@@@.@@@@.@@..@@@.@.@.@@@@..@.@..@@@@..@.@@@.
.@@@@@@@@...@@.@@.@@@.@....@@@@@@@@@@..@@@@@.@@.@@@@@@@@.@@.@@@....@@@@@.@@@.@..@.@@@..@..@@@@@.@.@.@@@@.@@@.@@@@.@@@@@@@@@@@.@.@...@@.@.@@@
@@@@.@@@@@@@.@..@@..@@@@.@.@.@.@...@@@@@.@@@@..@.@..@@@.@@@@.@@...@@@..@...@.@@.@@.@@@@.@.@@.@@@@@..@@@@..@@..@@.@..@@@@.@.@@@.@@@.@@@@@.@@@
@..@@@@@.@@@..@@@@.@.@@@@.@.@..@@@@@@@@.@..@.@@.@@@.@@.@@.@@@.@@@@@@.@@..@@@@@@..@@.@..@@@@.@.@.@@@@@@...@@.@.@.@@@@@.@@@..@@.@.@.@@@..@@.@@
@@@@..@@@.@@@@@.@..@.@..@@@.....@@@@.@@.@..@.@@..@.@@@@@..@@@@@.@.@@..@@.@@@@.@@.@....@.@@@.@@@@.@@@@.@@@@.@@@@.@.@@@@@.@@@@@.@@@@@@@@.@.@@.
.@@@@@@@@.@@@....@@@@.@@@@@@@@@@@@@@.@@.@.@@@.@@@@@@@@@..@..@@@@@@@@@@@.@.@.@@@@@.@@@@...@@@@...@@@@@@@@@@.@.@@@@@@@@@..@@@@@..@.@@@@@@@@.@@
@@@@.@.@@.@...@.@@@@.@@@@@@..@@.@..@.@@@.@@@@@.@@.@.@@@.@.@@..@@.@@@@@@@.@.@..@@@.@@.@@@@@@.....@@.@.@@@.@.....@@..@@@@@@@@@@.@@@@.@@.@..@@.
@@.@..@@.@@..@@.@@@@.@@..@..@@.....@..@@@@@@@@@@@.@..@@@@@.....@.@@@@@@.@@@@@@..@@@.@@@.@@@.@.@@.@.@.@@@.@@..@..@@@..@@.@.@@@@@.@@.@@...@...
.@.@@@.@@@@.@.@@.@.@@@.@..@@@@@@@...@@@..@@@..@.@@@@@...@.@.@@@@@.@@@.@@@@...@@@@@@.@@..@@@@@.@.@.@@.@.@@@@@@.@@@@.@.@@@@@@..@@...@@.@@..@.@
@@@@.@@@..@.@@@@@@@@@@@...@@@.@..@..@...@.@@.@@@@@@@@.@@@.@@@@@@@@@.@@@@@@@@@@.@@@.@@@@...@.@.@@.@@@.@@.@@@@..@.@@@@@@.@@@.@.@@.@@.@@@@@@..@
@@@@..@@@..@...@.....@....@@@@..@.@@@@.@@.@@.@@@@.@..@@.@.@@@@@@@..@..@@@@..@@@@@@@@@@@@@@@@@.@@@@@.@.@@@@@.@@@..@@@@@@@@...@@..@@@@.@@.@.@@
.@..@@.@.@@@@...@..@@@@.@@@@@.@@@@@@....@@@.@@.@..@.@.@.@..@@@@@..@@.@@@@.@.@@@@@@@...@@@@@@@..@@@@@..@.@@@..@@...@@@@.@@@..@...@.@@@@@@@.@.
@.@@@@.@.@.@.@@@@@@.@@@..@@.@.@@@.@@..@.@@@@..@@@@@@..@@.@..@.@@@@.@@@@.@....@@..@@.@@.@.@.@@...@@@@...@@.@@@.@@.@@@@@@.@@.@@.@@@@@@@.@@@@..
@.@@@@@.@@@@@@@@@@@@@@@@@@@...@.@@@@.@@@@@@.@.@@@@@..@@@@...@@@@@@.@@.@..@.@@.@@.@@@@@.@@@@@.@@@.@@@.@@@..@.@@@@...@@@@@.@@.@@@@.@@@@@@@@@.@
@..@@.@@.@..@...@@@@..@@@@@@.@...@...@.@@@@@@.@.@.@@..@.@.@@.@@@@@@.@.@.@..@@@@@..@.@@@@@@.@@@.@@@@@@@@@@.@.@@@@..@..@.@.@@@.@@@@@..@@@@@.@.
.@@@@@@.@@@.@@....@...@@.@.@@@@@@.@@@@@@@......@@@@@.@@@...@@.@@.@@@...@..@@@@....@.@@@..@@@@@@.@@@@@@.@@@@@@@.@@.....@@@@@...@@.@@@@@.@@@@@
@@@@@@.@@.@.@@@@.@@@@@@@....@@@@.@@@@.@@@.@@@..@@@..@.@@@@..@@.@@.@@@.@.@...@..@.@..@..@@..@..@@.@@@@@@.@....@@.@@.@.@.@@@@@....@..@@@..@@.@
.@.@..@@.@@@..@@@@@@@..@..@.@@@@.@....@@@@@@..@@@@@.@@@.@@@@@@.@@@@@.@..@@@.@@@@@@@.@.@@.@@@@@@@@@..@.@@.@.@@@.@..@@@@@.@.@@.@@@..@@@@@@.@..
@@@@......@.@@@.@.@@.@..@.@.@@@@@.@@@@@@.@@@@@.@@..@@@@@.@@@@@.....@@.@@@@@@.@..@@@...@@@.@.@..@@@@.@@@@@.@@..@@@@@.@@@@@@.@@.@...@@@.@..@@.
@@@@@..@@@.@@@@@.@@@@@@..@@@@...@@@@@@....@.@..@.@.@..@.@@@.@.@.@.@@@@.@@..@@.@.@.@.@@@@@@@@..@@.@@@@.@@@.....@@@@@..@@@@@@@.@.@@@@.@.@...@@
@.@@@..@@@..@@.@@@@@@@@...@@@@.@@@..@@@.@@@@..@@..@.@@..@@@@@..@@.@.@....@@@@.@.@@@.@.@.@@.@@@@.@.@.@@@@@..@@@@@@@@..@@.@...@@..@@.@@.@..@..
...@@.@@.@.@@@@@.@@@..@.....@@..@@.@@.@@.@@.@...@.@....@@.@@@.....@@@@@.@@@@@@@.@@@@@.@.@@@...@@@@.@@.@.@.@@..@@..@@..@..@@..@.@.@.@@@@@..@.
@@.@@@@@.@.@@@@..@@@@@@@@@..@@@@@.@@.@@..@.@@.@@..@.@@...@@@@@@.@@...@@@@@@@.@@@@..@.@@.@@..@@.@..@@@.@@@.@..@@@.@.@@@@.@@@@..@.@@...@@@@@@.
@@@@...@@..@@..@@@@@@..@...@@@@..@@@@.@@@@@@.@.@@@@@..@@@@@@..@@@..@@.@@@@@@@@@.@...@@@@.@@@...@@@@@..@@@..@.@..@..@@.@@.@..@@@...@...@@@@@.
.@.@@..@@.@@.@@...@@.@..@@@.@@@@@@.@.@@.@@@@..@.@@@.@..@@@@@.@@@@.@..@@.@..@..@@@.@..@@@@@@..@.@@@@@@@@@.@.@@.@@@@.@@@.@@.@@..@@.@@.@@@@@.@@
.@@.@@@@...@@@@..@.@@@@@.@..@.@.@.@.@@@@@....@.@..@@@@@@@@@@..@@@@@@@.....@@.@@@.@.@@@@@@...@..@@.@@@..@@..@@@@...@.@@@...@@@@@..@..@@@@@@@.
@..@.@@@@@@@@....@@@@@@....@@@.@@@.@@@@@@.@@@@@.@..@@@@@...@@@@.@.@@@@..@@@@@@@.@@.@@@@@.@@@@.@@.@@@@@@@@@@@@@@.@@@@..@@.@@.@.@@.@..@@@.@@@@
...@@.@@.@@@@@@@..@@...@@@@.@@@@@...@.@@@@@@@...@@.@@....@@@..@.@@@..@@..@.@.@@@@...@@@@@@@.@@@..@@@..@@@@.@..@.@..@@.@....@@@.@@@@..@..@.@@
@...@.@@.@@@@@@@@@@@@@@@@@@.@@@.@..@@..@@.@@.....@.@@.@@..@@@.@.@@@.@.@@..@@@.@..@@.@@@@@@.@@@@@@.@@@@@.@.@@@@.@@..@@.@@.@@@.@..@@@@..@@.@@@
@@.@.@@@@@@@@...@.@@@@@..@@.@....@@@@@..@.@@@.@.@@@.@@.@@@@.@@@@.@..@@@.@@@@@.@@.@@@@@@..@........@.@.@@..@.@@..@@@@.@@..@@@@@.@@@@.@.@@....
@@@@.@...@@.@.@@..@..@@.@..@@..@@@.@@@.@@@@@@@..@@@@@@@@@@.@@@@.@@.....@@@@@.@...@@@@.@@@@.@@.@@@@.@..@@@@.@.@@@.@@@.@@@@@@@.@.@...@...@.@.@
.@...@@@.@@@@.@@..@@...@@@@@@@.@@.@@.@@@@@@@.@@@.@@.@@@@..@...@@.@@..@..@.@@@@@...@@@@@@@@@@.@@.@@.@@@......@.@@@@@@.@.@@@@@@@@@.@@@.@.@.@.@
@@@@@.@.@@@@@..@@.@@@@.@@@.@@@@@...@.@@.@@..@.@@.@.@@@@@..@.@@@.@@..@@@.@@..@...@.@@@@@@@@....@@@@@@@.@@..@@@.@@@@@@@..@.@.@@.@@@@@@@@@..@@@
@@@@@@@@@@@@.@@@@.@@@@@.@@.@@@@.@.@@@@@@.@.@@@@...@@@@..@@.@.@.@@.@...@..@..@@.@.@..@@@@@.@@@@@@@@.@.@@@@@..@..@.@@.@.@@.@@.@.@@.@@.@..@.@@.
@.@@..@@@@@.@@@@..@.@.@.@@@@.@@.@@@.@@@@@@.@@@@.@.@@.@@@@@..@.@.@.@@.@.@...@@..@.@@.@@@.@.@..@@@@@.@@@@@@@@@.@@@@.@.@@.@@@..@@@@@..@.@@@@.@@
..@@@@@..@..@..@@@@@@.....@.@@@@@@@@...@@....@.@@@..@..@.@@@@@@@@@.@.@@.@@@.@@@@.@@..@@.@@..@.@...@@.@@.@@.@@.@@@.@@@@.@.@@@@.@...@@@@.@@@@@
.@@@..@..@.@@@..@.@@@..@.@.@.@@@@@@@@@..@@@.@..@@..@.@@@@.@@.@@@....@@.@@@@.@@.@@@.@@.@@@@@@@.@.@@@.@..@@@@@.@.@@.@@..@.@.@.@.@.@.@.@@.@@.@@
@@@@@@...@.@@.@.@..@@@..@.@.@.@@..@@.@@.@.@@@@..@@.@@.@.@.@@....@@@@@.....@@.@@@.@@.@@@@@@@@@@@@@@@@@..@@.@..@@@.@@..@@.@@@@@@.@.@@@@@@@@.@.
@@.@@..@@@.@@.@@..@.@@@@...@@@.@@..@@@@@@.@@@@@.@@.@@.@@@.@@..@..@.@@.@@@..@@@@@@@..@...@..@@..@@@@@..@@..@@.@.@@.@@@@...@.@@@@.@@.@@@.@.@..
@@@@@@@@.@.@.@@@.@.@...@.@@@@@@@..@@@.@.@@.@@@..@@@...@.@@@@@@@@@.@..@@@.@.@@@@@@.@.@.@.@...@@@@.@@@@@@.@@.@@@@.@@@@@@.@@.@@@.@@@.@@@@@...@.
.@@@@@.@@.@@.@.@.@@@..@..@.@@@@@@...@@..@@.@..@@@@@@@@..@.@.@@..@.@.@....@@@@@.@.@@@@..@.@@@@@@@....@.@.@.@..@@.@..@@@@.@....@@@@.@.@..@@.@@
@.@@@@@@@@.@@@...@@.@.@.@@.@@@.@..@@..@..@@@.....@@...@@@@@@@@@.@@@..@@.@.@@@..@@@..@..@@@..@@@@@@@@..@@.@@@@.@@...@@.@.@.@@@@@@.@@@.@@@@.@@
.@@..@.@@@@@@.@@@..@@@.@..@@@@@@@@..@@@..@.@@@.@.@.@@@@@@@@.@@@@.@.@@.@..@.@@@@...@..@@@@@@@..@@.@@.@@@.@@@@@@..@@@.@@.@@.@.@@.@.@@@@@@.@@@@
@.@.......@..@@......@.@.@@@.@@.@@@.@@@.@.@@@.@.@.@.@..@.@.@@@..@@@.@@@@@...@.@.@@@..@.@.@@.@.@.@@.@.....@@@@.@@@@@.@@.@.@@@@....@..@@@.@@@@
@@.@@@@@@..@@@.@@@@@...@@.@@.@.@@@@@.@@.@@..@@@.@@@@@@...@@.@@@@.....@@@@..@@.@.@.@.@@..@..@@@.@@@@@.@@.@.....@@@@.@@..@...@@.@@..@.@@@@@.@.
.@@@@@@@@@.@..@..@@.@@@.....@.@@@@@@@@@..@@@.@@.@..@@@@.@@...@.@.@@@@@@....@.@@.@.@@@.@.@@@.@.@.@.@@@.@@@@@@@@@@@.@@.@@@@@@@@@@.@@@@..@@@.@@
...@..@@@.@@@@@@@...@@@..@..@..@.@..@@...@.@@@@..@@.@@@..@.@@.@.@.@.@...@.@@.@..@@.@@@......@@@.@.@@@@.@..@@..@..@@.@.@..@...@@@.@@@@.@@.@@@
@.@@..@@@@@@@.@@@@@.@.@@@.@@@@@@@@@@.@@@@@@@.@....@@..@@.@@@@@@@@@..@@.@.@.@@@.@@@.@@.@.@...@@.@@.@@@.@@@.@.@.@@@.@.@@@@@.@@.@.@@@@.@@@@@.@@
.@@.@@@@.@@..@@@@@@@@@@@@.@....@@@....@@.@..@.@.@@@@.@.@@..@.@@@@.@.@@@.@.@@...@@@.@.@@.@..@.@.@.@@@.@@@@@.@@.@@@@@.@@..@@.@@@@@@.@@@@@.@.@@
@.@@@.@@.@@@.@@@@@..@@@.@@@@@.@@...@.@..@@@@@@..@...@.@@.@@@@..@@@.@.@@.@@@.@@.@@@@.@@.@@.@@....@@@@@@@@@@@..@@.@.....@.@@@@..@@@@@@@..@@@.@
...@@@@@.@..@@.@@..@..@@@@.@....@@@@.@..@.@@@.@@..@@@.@.@.@...@@@@@.@.@@@@....@.@.@@.@@@@@.@@@.@.@@@.@@@@@@@.@..@@@.@@@@@@@..@@@@@.@@@.@@@@@
.@@.@@@@@.@@@@@@.@@..@@.@@@@.@@@@@@@.@@@.@@@.@@@......@@.@@@@@@@@@@@@@@@@@@@@.....@@.@...@@..@@.@.@.@@@@@@@@.@@@@@..@..@.@@@@@.@.@@..@@.@.@.
.@..@.@.@@@.@.@.@.@.@@@@.@@@...@.@.@.@@@.@@.@.@@..@.@@@...@@@@@@@@@@@.@@..@@@@@@@@@@.@@@@@@.@@@@..@@.@.@@@@.@@@......@.@...@@@@@..@@.@@@@@..
@..@@@@@.@@@@@@...@@@..@..@@@@@@.@.@@..@@@@.@..@@@@@.@@@..@@@@@@@@@@@@@@.@.@.@@.@@...@@@@@@@@@.@..@@..@@@@.@@@@@.@@.@@@@@@@@.@@@.....@...@@@
@.@@..@@..@@.@@..@@@@@.@.@@.@@..@@@.@.@@@.@.@.@..@@.@...@@@.@@@@@.@...@..@@..@.@@.@@@@@@@@@@...@@@@..@@@@@@@@@.@.@..@@@@.@...@@@.@..@@.@@@.@
.@@@@.@@.@@.@@@.@@@@@@.@.@.@@@.@@.@@@@..@@@@.@.@.@@.@@@@@.....@@.@.@.@.@@@@@.@@@@@@.@@@@.@@@.@@@@@.@..@..@@@.@.@@@@@@@..@@.@...@..@@@@@@...@
@@@@@.@@@@@@.@@@@@..@.@@...@@@@@@@@@@@@...@..@@.@..@@.@@..@...@@.@@@@@@@@@@@.@@..@..@@@@@@@@@.@.@@@@.@.@.@....@..@@@@...@@.@.@@.@@.@@.@@@.@@
@@.@@@@.@@@@.@@.@@.@@@@@@@..@@@.@@@.@@..@@@@@@@..@@@...@@@@.@@.@@@..@@@.@@..@@@.@@@@.@@@@@@@@@@.@.@@@@@@@@@..@@@@.@@@.@@@@.@@@@@@..@.@@@@@.@
@.@@@@.@.@.@@..@@@..@.@....@@@@@.@.@@.@..@@@@@@@@@..@.@@@..@@.@@@@@@@@@..@@....@@@@@.@@.@.@@@...@.@@@.@@.@@.@@@.@@.@..@.@.@@.@@@@@@@.@@@@.@@
@@...@@@..@@@@.@.@@@..@@@@.@@.@..@.@@..@@@.@@@@@@@@@@@@@@@@@@@@@@.@@@@..@.@@.@.@@@@.@@@..@@.@@@..@@@.@@.@.@@@.@@@.@...@@@.@@.@@.@@...@@...@@
@.@@@.@@@@@@@@@.@@@....@..@......@@@.@@.@..@@@.@@@@@@.@@..@@@@@@@@@..@@@..@@..@@@.@.@.@@@@@.@@@.@@@@@@@.@@.@@@@.@..@@.@@..@@.@@@@@@.@..@.@.@
@@..@...@@@@@@@..@@.@.@@.@@@@@..@@..@@..@@.@..@..@@@@..@.@@.@@@@..@..@@.@@@@.@@@@@.@@.@.@@.@@...@@@@@@@@@...@@@@.@@..@@@@@@@@.@.@@.@@.@..@@@
.@@@.@.@.@.@@@@@@...@@...@@.@.@@.@@@@@.@.@@@@@@@..@@.@@..@.@@.@.@.@.@...@@@@@..@.@@@@.@@@@.@@@@@@@...@.@...@.@@@@@.@.@.@.@@..@.@..@@@@.@@@@.
.@@@.@.@@@@@@@.@@@.@.@.@...@.@@..@@@.@@@@@....@@@@...@@@.@.@@.@@@@..@@@@@@.@.@@.@.@....@@@@..@@@@@@@.@@@@@@.....@@.@@@@@@.....@.@.@@@@@.@@@.
@@.@...@@@@@@..@.@@@@@..@@..@@.@@@.@@@@.@@@@.@@@@@@@@@@@@.@.@.@@.@@@@@..@@.@.@.@@@...@@@@@....@@.@.@@.@..@@@.@@@@.@@@@@@@@.@@@@...@.@@@@.@.@
@@@@@...@@...@.@@@.@@.@@@@@@@@@@@@@.@..@@@...@.@@@@@@.@.@..@@@..@@@@..@.@@@.@@@@@...@@...@@..@@..@@.@.@..@@...@@@.@@@..@@@..@@@.@.@@@.@@@@.@
..@.@@@..@@@.@@@..@@.@@.@@@@@...@@.@@..@@@.@@@@.@@...@@.@@@@@@@@@@@@@@.@@..@@..@@@@@@..@.@..@@@@@@@....@@...@@@@@@@@@@.@@@.@@@@@@@..@.@....@
@@@@..@@@@@@@@@@@@@@@@@@@...@.@@@@@@@@@.@.@@@@.@.@@@....@@@@@.@@...@...@@@@...@@@@.@.@@.@@.@@..@@@.@..@..@..@@@@@@..@.@@@..@@.@@..@@.@@...@.
.@@..@@.@@.@@@@..@@@.....@@@@@@@@.@@.@@.@..@@.@@@....@..@@@.@@@.@.@@@@@@@@@.@..@@@@.@.@.@@@@@..@@.@..@@.@@..@.@.@@@.@.@@@@@@@@@@@@@@.@@..@@@
.@@@@.@..@@.@@@.@@@@@.@@@...@@@.@@@..@.@.@@@@..@.@@@.@..@.@......@.@@@.@@@.@@@@..@.@.@.@.@@@...@@@@.@.@@.@@..@@@@@.@@@@..@....@@.@@@@.@@...@
@@@@@....@@@@.@.@.@@@@@@@@@@@@@.@@..@@..@@@@@@...@@.@@@.@@@@.@@...@@.@..@@.@@.@.@@@.@@@.@@@@.@.@@.@@@@@@.@@@@.@.@.@@@@...@@@@.@@.@@@.@@...@.
@.@@.@.@@@...@@@....@@.@.@@@@.@@@....@.@..@.@@@@.@@....@@@....@@@@@@@@@...@@@@@@@@@@.@@.@@@@@@@@.@@@....@..@.@@@.@@@@@..@..@.@....@@...@..@@
.@.@@..@@@.@.@@@@@.@@.@..@.@@..@..@@@@@@@.@@@..@@@@..@@@@@@.@@.@...@..@@@@@@@@@@@......@.@...@@.@.@.@@@.@@@@...@.@@.@@.....@@.@.@@.@.@...@@.
@@@@@.@@.@@@.@@@@...@@@..@@@.@@@@.@@@@@@@.@@@.@@@.@.@@.@@.@@@.@@@..@.@.@@..@@@...@.@@.@@@.@@@@.@@@.@@..@@@....@..@@@@@.@@.@.@..@@@@@@@@@@@@@
@@@@.@.@@@.@@@....@.@....@.@..@@@@@@@@..@@@..@@.@.@..@.@@@@@.@@@..@.@.@@@.@.@.@..@@..@@@@@.@@@@@@@..@@@@@...@.@@@@.@.@..@.@@@@..@.@@..@@.@@.
@.@@@@@@@@@...@.@@@....@....@.........@@@@@@.@@..@@@....@@@@@@..@@.@@@@@.@@..@@@@.@.@.@@.@..@@@.@.@..@@@@@.@@@@@.@@@@.@.@@@@@..@@@@.@@@@@.@@
@..@@...@@..@@@@@.@@@@..@@.@.@.@@.@@@.@@@.@@@@.@@@@.@@@@.@@.@..@@@@@@.@@.@.@@@@..@@@@@@@@.@.@..@@.@@@@.@@@..@@@...@@.@@@..@@.@..@@@@@.@.@@.@
.@@.@.@@.@@..@.@@.@@.....@@.@@...@@.@..@@@.@@@..@@@@..@@..@@..@..@@@@@@@@...@.@.@..@.@...@@@@@.@@@@..@@@@@@.@..@@@@@@@.@@@@.@@@@@@@.@@@@.@@.
...@@@@@.@@@@@@@.@@@..@@@...@.@@@@@@.@@.@@@.@@@@.@@@@@@.@@.@.@..@@.@@.@..@.@@@@@.@..@.@@@@@@@@..@@@@@@.@..@@@@@..@@@@@@@.@@..@@@.@@@@.@@@@.@
....@.@@@....@.@@@@...@@...@@.@@@..@@..@.@@@@@..@.@..@@@@.@@@.....@@@.@.@@.@@..@.@@.@..@.@@@..@@@@@.@@@.@@.@@@.@@..@@..@.@@.@.@@@@@@@@.@@@@.
@@@.@.@@.@@@@.@@@@@@@.@..@@.@..@@@.@.@@.@@@.@@@@.@.@@.@.@@@@.@@@@...@@..@.@@@@@..@.@@@@@@@.@...@@@@@@..@.@@@@@@.@@.@...@.@@.@@@@@@@.@@.@@@.@
@..@.@.@@@@@@@.@.@@.@@@...@..@.@.@@.@@@@.@@@.@@.@.@.@@@@@@@@@@..@@.@@@.@@.@.@@..@@@@.@@@@@..@.@.@..@@@@@.@...@@@@@@....@.@@@@@.@..@...@@@.@.
@@@@..@..@.@@.@.@.@@@@@@.@@@.@..@.@@@@@@@.@@@@.@@@@@@..@.@.@...@@@...@@@.....@.@@.@.@@@.@@@@.@@.@@..@@@....@@.@.@.@...@.@@@@..@@@@@.@@@@.@@@
...@.@@@@@@.@@@@.@.@@.@.@.@@@@.@.@@@.@.@@@@@@@@@@.@..@.@@@..@@..@@@.@.@@@@@.@@.@@@@@@@@@@.@@@.@@@@.@@.@@.@..@@@..@@.@.@.@.@@@.@@@@@...@@@.@@
.@@.@.@@@..@@.@@@@@.@@@@@.@..@@.@@@..@.@@..@@@@@....@.@@.@.@@@@@@@.@..@@@@@.@@.@@@@.@@.@.@@.@@@@@@.@@....@.@.@.@.@@.@@@.@@@@@@@@@@.@..@.@..@
.@.@@@@@.@@.@@@@@.@@@.@@@@.@@@@.@@@.@@@.@.@@.@@@@@.@@@@@..@@..@@..@@@@@.@.@@@.@@@.@@..@.@@@.@.@@@@@@..@@@.@@@@@.@@@.@..@@@@@...@.@@....@@@..
....@..@..@@@.@.@..@@..@@.@.@@@@.@@@....@@.@@.....@.@@@.@@.@@@.@@@.@..@@@@@@@.@@.@@@@@@..@.@@.@@@@.@.@@@@.@@@@..@@..@@@..@.@..@@.@@@@.@@@@@.
@@...@@@@@@@.@@....@@.@.@.@@..@...@@@@@@...@@.@@@..@@.@@@..@@@@.@..@@@......@@@@.@@.@@@.@@.@.@@@@..@@@@.@@@.@@...@.@@.@@@@@.@@@@@@...@@..@@@
@@@@.@@@@.@.@@.@@.@@@@@..@.@@@.@@@@.@..@@.@..@.@@@@.@...@@.@..@.@@.@@@@@@.@.@@@@@@@.@@@@@.@@.@.@@@.@..@@@@@@@@@@...@@.@@@@@@@@@@@..@..@@@.@@
..@@@@.@@@.@@.@@@@@@@@@@@.@@@@@@@@.@@@@@@.@@..@@@@..@@@..@@@@...@@@.@@@@@@@@@.@@@.@@@..@@@@@@.@@@@@@@@@@@.@@@@.@.@@@..@@@@.@@@@@@@@@@@@@@@.@
@@@@@@@@...@.@@.@@.@@..@@.@@@..@@@..@@@.@.@.@@.@@@.@@........@@.@@@@@..@@@@@.@.@.@@@@.@.@@..@@@@@@@@@@@..@@@@@..@@@...@@@@@..@..@.@@@.@@..@.
@.@.@...@@@@..@@@.@@@@@.@..@.@@.@.@@.@.@@.@@@@@@@@@@.@@@@.@@@@.@@@...@.@@.@@@@@@@@@@...@@...@.@@@....@..@@@.@@@@@..@.@.@@@@@.@@@@...@..@@@.@
.@.@@....@@..@@@.@@@@@...@@@@@@@@.@.@@..@@@.@@..@@@@@@.@@@@@@..@@@@..@@@@@.@@@..@@@@@.@@.@.@@@@@..@@@@..@.@..@.@@@@..@@@@@@@@.@...@.@@@.@@@@
.@@..@@@@@.@@@.@@@@..@@@....@@@@...@.@@@@.@.@.@@@@.@....@@@@@@.@.@.@@@@.@@@..@@@@@..@@@.@@.@.@.@@...@@..@.@..@@@@@@@@.@..@..@@@@@@..@@@.@.@@
@@@..@@@.@@@@.@@...@.@@@@..@@@@@@@@@@@.@@@.@@.@@@@.@@@.@@.@@.@.....@@@@.@@..@.@@@.@.@@@..@@@.@@@@@.@@.@@@.@.@@@@@@@@@...@@..@.@@@@@.@.@.@.@.
.@....@@@@..@.@@@@@@@.@@@...@@...@@@@@@@.@.@@.@@...@@@.@@@.@.@..@..@@@@@..@@@@@@@@@.@....@@@@...@@@..@.@....@.@@@@@.@@@..@@@@..@@@..@@@.@@@.
@@..@@..@@@@.@@..@..@@@.@@.@.@@@@@@@@@@@@@@.@@@@@@@.@@.@@@@@@.@@.@.@@.@@@..@@.@.@@@@@@@..@@...@@..@.@@.@@@@@@@@.@@.@@@@.@@@..@@@@@@....@@@.@

38
5/ex1.py Normal file
View File

@@ -0,0 +1,38 @@
import bisect
count = 0
intervals = []
with open("input.txt" , "r") as file:
for line in file:
line = line.strip()
if line == "":
break
start, end = map(int, line.split("-"))
intervals.append((start, end))
intervals.sort(key = lambda x: x[0])
merged = [intervals[0]]
for current_start, current_end in intervals[1:]:
last_start, last_end = merged[-1]
if current_start <= last_end:
merged[-1] = (last_start, max(last_end, current_end))
else:
merged.append((current_start, current_end))
for line in file:
line = line.strip()
starts = [i[0] for i in merged]
number = int(line)
index = bisect.bisect_right(starts, number)
if index == 0:
continue
start, end = merged[index - 1]
if start <= number <= end:
count += 1
print(count)

28
5/ex2.py Normal file
View File

@@ -0,0 +1,28 @@
import bisect
count = 0
intervals = []
with open("input.txt" , "r") as file:
for line in file:
line = line.strip()
if line == "":
break
start, end = map(int, line.split("-"))
intervals.append((start, end))
intervals.sort(key = lambda x: x[0])
merged = [intervals[0]]
for current_start, current_end in intervals[1:]:
last_start, last_end = merged[-1]
if current_start <= last_end:
merged[-1] = (last_start, max(last_end, current_end))
else:
merged.append((current_start, current_end))
for interval in merged:
count += interval[1] - interval[0] + 1
print(count)

1175
5/input.txt Normal file

File diff suppressed because it is too large Load Diff

23
6/ex1.py Normal file
View File

@@ -0,0 +1,23 @@
import numpy as np
LINES_NUM = 5
COLS_NUM = 1000
count = 0
probs = np.array([])
with open('input.txt', 'r') as file:
for line in file:
for num in line.split():
probs = np.append(probs, num)
probs = probs.reshape((LINES_NUM, COLS_NUM))
for col in probs.T:
if col[4] == '+':
count += int(col[0]) + int(col[1]) + int(col[2]) + int(col[3])
elif col[4] == '*':
count += int(col[0]) * int(col[1]) * int(col[2]) * int(col[3])
print(count)

42
6/ex2.py Normal file
View File

@@ -0,0 +1,42 @@
import numpy as np
LINES_NUM = 5
count = 0
probs = np.array([])
with open('input.txt', 'r') as file:
cols_num = len(file.readline()[:-1])
file.seek(0)
for line in file:
line = line[:-1]
for char in line:
probs = np.append(probs, char)
probs = probs.reshape((LINES_NUM, cols_num))
nums = []
skip_col = False
for col in probs.T[::-1]:
if skip_col:
skip_col = False
continue
nums.append(int(col[0].strip() + col[1].strip() + col[2].strip() + col[3].strip()))
if col[4] == '+':
print("Adding:", nums)
count += sum(nums)
nums = []
skip_col = True
elif col[4] == '*':
print("Multiplying:", nums)
prod = 1
for n in nums:
prod *= n
count += prod
nums = []
skip_col = True
print(count)

5
6/input.txt Normal file
View File

@@ -0,0 +1,5 @@
155 1 62 1925 984 83 723 832 57 1 134 44 6 55 95 4 3 4146 88 7 63 249 6 79 933 87 829 3 89 533 99 5575 38 27 9729 8 5495 74 8115 6 291 13 7 52 427 85 8 63 18 61 37 14 83 49 6 52 846 46 8 7 3 349 134 8 74 4 641 4649 89 88 63 31 53 87 166 1266 87 75 8698 27 199 21 5 794 84 293 882 33 7 48 54 62 51 49 16 73 37 5 27 47 85 869 1 772 83 48 5 12 6941 29 71 12 2 7 64 7 97 61 2314 856 1 3 557 16 84 32 249 35 2 262 355 8177 956 225 167 122 68 16 53 63 31 8 46 122 976 698 4 45 66 7235 7443 17 7366 32 2288 45 398 495 74 45 885 51 28 9 21 39 513 16 353 9 12 414 9 77 413 953 2 3 4 644 52 81 1637 6 43 7 69 9 511 47 937 27 593 7 2 56 749 46 152 4 12 25 6574 686 89 528 838 81 56 3 81 77 44 254 8 427 475 921 386 2338 2 6114 2 35 445 871 698 4 64 52 23 81 12 39 4172 3 16 14 213 48 47 9 54 33 5 9485 82 614 427 36 45 74 2 48 378 9 291 4 75 741 545 6 15 939 2 6358 2315 3418 531 97 21 23 355 36 2873 62 55 54 88 92 73 44 87 2792 9 79 523 34 29 86 7 388 4153 8 96 9 19 1 27 713 3 4 85 253 661 49 181 71 61 7 74 12 744 948 8 565 42 83 76 163 28 63 6835 32 4597 34 781 721 87 391 633 3 6466 3554 394 43 686 6 33 53 1 4114 788 434 41 31 726 8 4 837 7 264 46 1 27 89 8 298 5 29 191 76 3 377 45 3 15 5 3 62 58 1138 839 7 55 2 191 29 2 646 38 68 29 3 3233 84 658 84 828 757 6 47 416 96 671 56 732 51 68 92 2 124 915 27 4666 2 63 962 895 1 214 771 27 6111 4832 1 4 91 3 38 4878 44 8391 8748 354 23 79 72 9 6 839 13 2 15 7 32 835 455 72 4 319 9441 44 94 58 7 266 272 71 99 1369 63 31 67 989 2 99 3 876 333 45 8 752 9 3 996 5 64 67 62 1 746 43 752 154 9 471 689 113 817 8 898 924 42 1 74 1432 36 756 42 37 5 4 67 82 293 76 215 54 44 6 7 88 15 49 29 233 88 18 31 746 512 118 34 8 843 7785 411 38 675 19 75 39 97 9 255 7 942 88 1 462 1 483 814 513 438 98 89 381 963 3 46 67 983 247 292 91 668 8 31 265 647 2789 8519 91 66 246 918 47 68 931 2 684 862 8 278 611 84 7554 357 92 1276 239 785 497 79 696 719 1139 9 588 685 23 8 91 97 12 56 1681 589 6936 19 795 781 88 31 68 63 921 466 32 5 41 828 743 743 72 61 9 847 98 9742 46 485 3 85 33 54 65 8744 58 486 964 86 656 96 98 232 276 35 957 19 332 3571 146 73 93 9 952 23 89 41 91 5992 459 481 9 94 84 87 559 43 383 3 25 882 84 292 2 59 28 35 843 944 14 27 54 4 7 924 1 9946 785 676 8996 1 57 43 2 14 8239 885 142 5383 48 429 32 593 49 5866 95 34 9 166 926 34 76 48 1 94 19 72 4 45 64 47 339 94 8 66 99 21 2114 32 56 416 91 7213 665 22 333 95 6695 827 325 993 68 84 17 79 3 113 851 472 874 2798 1 5871 411 9 27 97 6829 87 453 56 2346 96 53 16 52 7 9 15 63 76 476 45 438 25 88 2 61 4 36 28 32 277 1 7 31 288 566 97 24 19 1671 297 539 25 24 2 9 1711 9 19 1 15 853 8 7122 89 491 57 32 156 45 742 18 587 773 6 752 5 2225 413 214 786 3 2 363 2957 6 2 797 6773 6715 2666 151 51 3 9 82 759 78 882 7523 75 3691 163 14 989 146 6 4 44 746 6 3 66 651 7 74 17 6688 75 954 574 9 8 224 5 61 7443 59 658 264 73 83 69 23 66 742 2 94 479 58 4426 854 8397 86 6 11 2931 9 7 2 561 73 82 472 443 65 45 5 89 1326 651 791 92 9416 16 91 2692 58 978 1469 151 85 49 6 477 34 18 66 9569 6 92 197 127 15 9 66 9 8239 61 98 98 51 39 59 43 535 1 39 3 25 789 52 2 2 912 88 92 644 8446 71 57 3 27 698 26 3 38 1 158 768 4367 8 48 5 9 9388 57 2 357 4 26 588 3 59 81 43 8 893 522 746 93 37 3 778 94 536 76 3 25 32 26 31 447 66 27 68 1 27 32 44 659 13 27 7 85 5542 454 3 92 761 79 832 5
614 4 39 3446 379 675 574 352 75 58 447 52 285 39 987 4 97 4371 22 177 14 563 53 43 459 94 161 163 94 184 448 4583 91 63 15 75 1232 19 8224 8 498 75 3734 595 885 268 14 26 33 595 76 72 19 52 13 12 263 41 1 25 1 327 224 65 76 86 932 6212 15 49 87 27 57 87 575 6337 85 31 3466 626 397 87 27 675 81 962 645 69 86 33 61 54 23 44 51 67 67 9 91 98 78 952 699 666 88 914 44 44 4963 33 117 75 8 8 13 13 72 47 2249 465 2 19 364 67 99 576 738 72 23 637 755 3435 695 468 125 112 98 796 59 42 17 1 78 683 957 3472 448 12 451 244 2312 32 8689 83 4796 72 391 882 66 55 568 23 266 95 47 28 256 16 295 69 68 7558 378 97 469 816 95 493 24 329 32 66 2668 94 66 5 23 69 1 2 946 88 214 85 97 46 939 18 544 95 23 91 589 122 6 673 597 46 52 93 12 8 686 569 93 934 111 681 179 9571 9 3744 4 47 298 451 793 775 98 98 28 29 42 69 1792 96 922 14 194 22 86 618 644 13 823 4372 68 716 239 42 71 38 4 61 444 22 388 3 37 314 315 96 24 119 32 1628 2667 11 848 29 274 48 945 16 5492 34 52 46 74 16 61 235 86 466 3 11 963 95 93 55 822 185 6644 55 21 851 77 1 8 564 4 39 12 552 1796 95 66 287 25 92 93 21 618 589 6 881 1627 88 47 822 95 78 667 8 5955 75 87 638 69 787 148 56 6573 7572 455 45 462 91 57 5 57 7872 484 748 64 7 851 41 362 796 77 842 12 6 689 91 4 16 85 66 391 2994 92 6792 83 6 44 31 25 56 14 1333 871 32 4 67 525 1288 47 535 87 31 73 19 5275 6454 518 71 6456 587 56 89 821 71 86 55 554 75 23 24 62 851 457 16 2615 79 37 424 368 82 397 952 25 2268 177 41 343 5 5 6638 6142 53 2132 2317 36 95 56 83 37 58 853 39 22 11 1493 639 627 785 969 7 498 9774 93 43 46 43 749 162 537 8822 8739 35 99 66 619 6 77 1 734 293 23 26 41 27 36 467 36 52 97 816 289 99 71 435 797 849 334 939 937 815 59 687 598 14 61 745 7882 51 649 764 54 84 9 52 952 481 762 135 52 962 9 33 55 97 56 39 81 22 97 367 5167 973 749 42 355 553 1593 519 97 784 869 94 88 52 4 468 38 991 63 41 334 9 916 983 825 819 18 8275 85 611 732 15 57 5863 6836 999 158 972 33 13 3647 56 6958 382 55 78 219 953 57 29 27 216 222 817 16 56 946 87 3396 146 63 8627 538 381 486 882 541 1524 2151 8 894 8578 962 4 94 59 14 47 4311 541 1584 6188 725 584 99 64 35 449 71 72 153 611 4 3577 624 245 77 15 64 996 9153 1685 478 592 7 51 63 431 754 688 18 46 871 78 1394 349 23 312 985 95 774 619 285 3296 292 88 28 41 522 158 8 28 26 3258 512 167 77 744 79 783 855 13 592 73 22 687 68 524 52 33 98 19 463 246 129 26 13 2 23 726 52 7159 456 686 6644 1 42 7 1 46 9261 711 483 1189 1 85 73 969 13 6842 96 457 1 712 422 81 29 25 69 56 47 678 64 18 75 65 83 428 782 36 49 59 2276 35 22 228 96 994 868 48 976 22 445 336 779 217 247 3547 11 185 38 824 251 814 2615 3955 91 4265 887 565 996 44 8825 827 158 99 7714 312 67 52 19 56 84 97 73 61 778 41 839 37 58 84 24 49 32 62 77 234 598 27 33 171 248 46 68 79 8345 133 988 11 32 16 9 4818 14 516 79 71 811 9 7833 983 178 55 46 44 25 946 443 638 921 42 167 34 2221 429 235 287 78 16 63 4143 84 82 617 7873 5813 2232 989 174 4 48 74 346 37 724 3461 27 22 667 94 717 973 441 92 74 399 5 8 26 592 17 62 46 7832 722 955 345 97 93 73 7 41 3271 22 881 653 67 37 86 6 82 574 19 59 11 725 1337 466 485 36 3 82 8113 3 511 5 742 9 19 968 92 545 81 37 8 1284 586 976 5147 6262 481 36 8151 83 191 5519 935 414 47 39 267 442 37 34 7176 7 879 494 728 4 12 39 62 8296 89 5879 56 93 36 46 35 547 253 96 5 73 275 48 88 12 684 21 84 7356 7291 627 76 43 58 454 29 7149 42 28 624 6431 5172 98 99 1 1 53 9238 72 372 22 16 479 13 3 63 69 66 37 35 587 468 225 13 837 9 834 976 34 26 16 56 24 444 44 11 89 7 31 8 16 646 397 323 45 91 715 261 845 47 795 49 582 4
89 3 85 486 42 855 95 654 776 32 163 36 348 92 131 22 95 866 3 269 44 9 591 45 41 144 142 959 36 576 576 227 3 68 8 49 8515 37 9552 51 579 62 1535 511 248 4778 76 66 71 267 62 11 78 421 973 451 549 36 43 48 246 41 39 29 626 355 715 4545 78 74 15 52 28 16 541 2744 394 65 5927 9843 632 51 36 89 51 18 846 37 136 34 67 91 648 81 41 27 59 3 571 9136 5 445 996 831 34 168 686 31 146 95 169 2 62 45 31 698 67 68 581 978 86 664 865 88 34 2139 776 9 64 929 547 223 4798 5 1377 443 43 412 33 43 81 81 19 271 62 5836 298 34 465 29 9846 3 9678 68 666 61 69 1395 47 3 552 2 562 35 521 23 231 74 8 4161 17 7727 546 84 514 535 55 725 63 454 6 13 6545 729 59 93 44 94 4 7 125 25 515 9781 34 2 886 997 352 67 15 49 853 754 5 724 433 6 6 99 7 3 157 934 84 293 73 185 52 671 5 1263 82 84 218 135 351 474 3 25 91 7 52 78 9823 65 845 44 477 99 37 1154 253 27 774 594 51 677 691 5 29 74 72 38 285 39 63 17 49 286 171 825 497 36 133 113 44 32 394 47 157 47 15 481 366 98 65 72 27 24 27 658 66 83 8 79 876 4 12 83 681 78 92 4141 98 919 96 42 2 766 31 96 33 754 6267 38 35 9556 64 25 61 29 655 54 49 236 9918 42 46 295 58 976 69 5 5396 58 17 475 8 212 674 23 298 2235 85 69 423 18 2577 4 17 168 471 99 24 1 47 343 214 497 44 1828 9 561 349 64 4 16 56 92 197 6283 47 1444 47 19 49 64 73 87 99 4568 9 17 3 14 61 1279 531 573 33 25 17 93 7166 3879 579 94 3155 837 87 57 619 63 23 4223 315 49 46 37 1753 2 581 11 8372 92 14 124 32 39 628 75 42 4348 89 785 785 3 95 6642 4818 88 662 4934 56 38 86 53 23 98 7 85 14 876 8168 375 59 992 953 28 367 118 81 23 2 68 156 26 9779 8195 2925 97 7 32 68 8 62 88 423 144 33 55 98 43 526 4 915 4 56 8836 746 3 1 66 193 975 922 413 611 846 41 74 113 82 121 291 9614 813 976 995 46 563 93 91 894 828 562 3642 1 378 4 93 773 39 6346 81 6 69 62 647 3884 989 919 196 927 888 2349 4491 716 92 444 29 621 116 89 48 27 158 521 76 371 6 59 892 854 4994 49 2878 61 791 541 26 8 7282 2851 2368 312 518 52 94 6377 5 2816 1 41 597 276 57 81 4 5 239 136 95 7257 91 184 31 119 697 35 7196 221 694 24 616 762 7652 1822 9 75 5544 354 66 26 378 69 87 13 664 867 1595 277 522 14 37 51 967 1 59 676 666 7 7339 545 6 96 62 2421 747 6675 9358 762 36 4 81 18 452 166 17 96 59 784 65 1825 331 74 98 71 42 131 929 65 7228 7 18 26 933 236 135 2 95 184 88 36 382 37 333 6 598 434 924 442 853 8 781 49 195 14 37 49 86 197 95 537 94 6 94 66 95 72 9726 948 51 47 93 45 4 15 64 2122 629 981 746 1 25 13 554 83 875 863 1468 8 5 899 372 35 3 32 48 67 239 65 97 71 94 85 565 592 61 62 87 5374 86 897 925 73 853 653 38 1 79 288 189 126 21 1819 8615 3 942 49 619 644 118 3835 8351 191 5639 657 438 471 582 7849 938 395 41 3716 461 442 36 1 511 51 3 9 27 551 3 313 86 5 79 99 568 76 45 63 96 1663 81 3 441 476 96 6782 69 7 184 45 47 61 954 84 4732 64 761 34 69 247 4 2943 111 354 262 89 63 44 29 7496 541 51 25 869 71 563 12 538 39 84 52 98 6486 19 428 163 6367 8336 113 65 556 37 75 89 92 92 392 4183 45 21 388 925 239 23 381 628 7 672 51 261 38 582 54 5 44 51 4841 75 152 421 48 6 6 56 828 78 369 962 71 57 83 1 92 763 73 39 22 1937 1494 62 568 493 192 98 6596 16 543 42 4 2 37 483 11 428 18 53 8 852 789 311 2734 5112 234 33 5391 12 63 1988 591 359 52 46 129 611 7 37 413 87 988 73 976 5 36 53 84 9382 572 7153 32 91 32 86 945 96 123 5 44 25 162 4 99 39 881 85 5 7777 555 862 63 549 11 996 48 9274 71 29 27 5495 236 223 741 27 14 4 1763 62 63 85 93 372 93 8 11 52 462 4 4 34 119 383 16 215 3 682 364 77 41 46 4 97 16 74 27 81 39 61 3 49 35 1759 6318 84 41 918 62 281 66 449 36 889 7
18 21 21 58 46 921 77 499 928 12 621 23 7138 741 361 15 44 476 7 265 15 5 654 14 26 649 284 136 97 48 329 742 5 6 9 869 3 98 6977 48 35 96 8962 462 1 5265 99 85 19 694 416 9 1 392 923 326 4 1 29 73 7379 8 7 23 437 584 616 428 695 29 43 15 7 71 119 526 398 96 49 2656 196 426 827 42 619 2 69 27 441 74 9 55 979 31 18 73 74 43 463 5711 3 21 698 67 53 946 964 78 213 8 136 6 16 45 48 984 47 77 759 554 38 258 45 64 96 3686 648 1 85 626 342 14 3497 5 3774 339 9 436 3 53 61 96 84 569 9 1612 683 95 129 49 77 2 2659 46 86 9 4 9112 62 9 5 9 224 77 189 97 8 21 7 9836 34 9339 778 93 5 94 32 688 65 997 8 58 2625 896 66 27 26 28 3 3 84 23 568 4955 51 5 999 696 717 911 72 41 82 35 5 858 699 4 1 24 8 6 8193 22 48 19 58 94 65 4 36 3781 14 26 789 5 12 212 1 39 76 6 1 5 5218 56 583 6 46 31 4 3294 624 23 178 61 88 22 76 2 37 81 34 1 492 78 6 56 53 43 628 318 216 3 129 294 71 93 377 6 364 37 25 275 783 2 92 45 36 5 35 959 76 1 57 39 454 3 11 9 128 7 2 2949 7 252 34 36 7 532 32 69 33 3351 4659 83 3 1266 83 35 4 9 371 53 866 63 6265 11 1 877 17 319 2 7 6455 63 9 675 5 57 78 65 565 457 59 3 9969 27 7836 1 39 2 44 54 162 7 34 275 328 334 26 9876 4 671 526 79 82 1 14 78 3 2822 53 7474 715 85 42 68 25 5 88 5358 1 393 9 69 47 7792 722 953 65 3 6 67 14 4787 491 64 5963 13 824 53 755 4 52 1835 22 7 73 37 9475 9 5 45 5637 69 14 247 2 16 58 9 77 8271 17 212 452 3 91 4227 5932 72 6 7251 35 7 67 94 444 318 5 19 71 914 2883 513 81 2 511 38 85 15 7 32 8 79 219 14 5682 4239 892 13 1 54 89 42 5 18 852 573 85 35 5 76 412 6 431 9 37 1319 261 7 6 27 63 181 13 573 738 272 58 3 37 45 623 951 37 745 74 948 84 627 13 28 598 9139 262 2817 7 448 63 71 427 5 7359 9 9 9 15 133 7653 73 988 879 517 89 77 4491 588 34 762 54 463 547 33 53 54 98 324 85 679 59 3 87 81 1258 2 6111 36 579 531 16 2 6376 1268 8861 636 593 621 81 8175 5 255 8 48 318 41 74 81 6 6 884 74 24 2584 92 97 27 36 31 56 96 94 547 49 369 76 8673 28 87 19 5854 126 61 41 538 56 82 37 574 55 3951 195 745 5 71 21 722 5 1 182 935 4 1226 281 4 95 74 2597 556 3355 7762 517 75 47 84 8 645 221 5 14 2 4 75 4541 827 2 53 7 1 717 699 6 739 6 95 14 951 638 984 2 58 252 1 87 962 14 849 6 321 64 317 9871 591 1 9414 3 415 72 9 63 82 53 3 988 3 2 63 16 12 78 59 33 75 53 73 61 9 95 7 7131 894 89 653 4 48 8 74 63 1 793 6952 19 2 653 966 36 4 13 6 8 695 22 5 33 79 55 557 914 92 82 547 478 23 792 1 6 17 25 1 6 26 2 31 29 1 2895 4838 1 817 98 626 94 67 5722 3 583 413 383 883 132 162 6811 746 3 8 533 197 731 24 9 236 47 8 1 47 922 6 7 3 3 65 76 565 3 97 81 14 5263 19 1 665 891 59 5139 6 5 344 4 23 8 355 34 67 73 256 89 68 77 39 672 593 424 415 54 3 886 57 4743 13 4 71 353 31 28 4 57 9 85 81 6 799 41 281 889 657 94 896 2 736 45 96 53 83 77 59 333 67 5 919 424 613 36 134 562 4 139 96 179 5 756 45 8 76 7 5981 9 74 867 71 3 82 2 725 38 83 19 22 2 29 9 37 14 96 5 77 6367 7825 6 47 1423 171 7 12 744 582 19 6 5 44 55 46 236 72 88 5 78 537 27 4432 36 757 89 835 59 9 667 6638 159 57 91 696 739 3 13 54 75 581 21 71 5 91 7 652 4794 386 8243 75 19 68 13 121 6 169 4 64 3 412 4 14 83 55 1 5 7274 169 161 53 484 4 234 96 7423 94 48 14 6683 769 812 981 64 53 6 9837 23 48 88 22 37 48 5 54 27 472 8 9 14 526 877 88 282 4 42 491 69 52 25 7 63 24 41 74 36 37 5 4 99 7 4419 5711 33 7 723 25 112 74 219 73 146 424
* * * + * * * * + + + + + * + * + + * * * * + * + + + + * * + + + * + + + + + * * + + * + + * * + * + + + * * * + * * * + * * * + * + + * * + + * + + + * + + + * * * * * + * + * + + * * * * + * * + + + * * + * * * * + + * * * * + * + + + * + * + * * + * * * + + + + + + * * * * * * + * * * + + * + + + + + * + * + + * + + * + * + * + * + + * + + * + * * * + + * * + + * + * * * * + + + + + + * * * * + + + * * + * * * + + * + * * * * * + + + + * + * * * + + * * * * * + * + * * * + + * + + + + * + * + + + * * * * * + + * * * + + + + + + * + + * * + * * * * + + + * + + * + * * * * * + + + * + * + * + * * + + * * + * * + + * * * * + + * * + * + + + + * * * + * * + + + * + * + * * + * * * + * * + * + + * * * + + * * * * + + + + * + * * + + + * * * * * + * * * * * * + + * + + + * * * + + + + * + + + * + * + * + + * * * * + + + + + * * + + * + + * * * + * + * * + + + * * + * + + + + * + + + * + + + * * * * * * * + + * + * + * + + + * + + * + * * + * * * * + * * + * * + * + + + * * + + + * + + * * * + * + * + * + + + * * * * + + + + * + * * + * + * + * * + * * * * + * + * + * + * + + + * * + * + + + + * * * + * * + * * * + * + + + * * + * * * + + + + + + + + * + + * * + + + + * * * + * * * * + + * + * + * * + * + + + + + + * * + + + + * + + + + + + + * * + + * + * * * * * * * + + * * * + * + * + * * + * * * + + + + + + + + * + + + + * * + + + * + * + + + + * + * * * + * + * + * + * + + + * * * + + + + + * * * * + * + + + + * + * * + + + + + + + + * + + * + + * + + + * * + + * + + + * + * + * + + + * * * + * * * * * + * * + * * + * + + + + + * * + + * + * * * * + + + + * * * * * * + * * + + * + * + * * * + + * + * + + + * * * * * * * + + + + * * * * * * * * * * + + * + + + + + * * * * + + + * * * * * + * * * * + + + + * + + * * + + * * * * * + * * * * * + + * + + * * + * + + + * * + * + * * + * + + + * + + + + * + + * * * + * + * * * * * + + + * * + + * + + * * * + * + * + + * * * + + + * * + * * + * * * * * * * * + + * + * + + * + * + * * + * + * * + * + + + + + * * * * * * *

33
7/ex1.py Normal file
View File

@@ -0,0 +1,33 @@
import numpy as np
count = 0
grid = []
with open('input.txt') as file:
num_cols = len(file.readline().strip('\n'))
file.seek(0)
num_lines = 0
for line in file:
num_lines += 1
for i in range(num_cols):
grid.append(line[i])
grid = np.array(grid).reshape((num_lines, num_cols))
beams = set()
for row in grid:
for i in range(len(row)):
if row[i] == 'S':
beams.add(i)
elif row[i] == '^':
if i in beams:
count += 1
beams.remove(i)
if i - 1 not in beams:
beams.add(i - 1)
if i + 1 not in beams:
beams.add(i + 1)
print(count)

32
7/ex2.py Normal file
View File

@@ -0,0 +1,32 @@
def count_timelines(grid): # Dynamic programming my beloved/behated
num_rows = len(grid)
num_cols = len(grid[0])
counts = [1 if grid[0][c] == 'S' else 0 for c in range(num_cols)]
for r in range(num_rows):
next_counts = [0] * num_cols
row = grid[r]
for c in range(num_cols):
k = counts[c]
if k == 0:
continue
if row[c] == '^':
if c > 0:
next_counts[c - 1] += k
if c + 1 < num_cols:
next_counts[c + 1] += k
else:
next_counts[c] += k
counts = next_counts
return sum(counts)
with open('input.txt', 'r') as f:
lines = [line.rstrip('\n') for line in f]
grid = [list(line) for line in lines]
total = count_timelines(grid)
print(total)

142
7/input.txt Normal file
View File

@@ -0,0 +1,142 @@
......................................................................S......................................................................
.............................................................................................................................................
......................................................................^......................................................................
.............................................................................................................................................
.....................................................................^.^.....................................................................
.............................................................................................................................................
....................................................................^...^....................................................................
.............................................................................................................................................
...................................................................^.....^...................................................................
.............................................................................................................................................
..................................................................^...^...^..................................................................
.............................................................................................................................................
.................................................................^.^...^.^.^.................................................................
.............................................................................................................................................
................................................................^.^.......^.^................................................................
.............................................................................................................................................
...............................................................^...^...^.^.^.^...............................................................
.............................................................................................................................................
..............................................................^.^.^...^.......^..............................................................
.............................................................................................................................................
.............................................................^...^.^.^.^...^.^.^.............................................................
.............................................................................................................................................
............................................................^.^.^.^...^.......^.^............................................................
.............................................................................................................................................
...........................................................^.^.^.^.^.^.^.^.^...^.^...........................................................
.............................................................................................................................................
..........................................................^.....^.^.^.^.^.....^...^..........................................................
.............................................................................................................................................
.........................................................^.^.....^.^.^.^.^...^.^.^.^.........................................................
.............................................................................................................................................
........................................................^.^.^.^.^.^.^.^...^...^.....^........................................................
.............................................................................................................................................
.......................................................^.^.^.^.^.^.^.......^...^.....^.......................................................
.............................................................................................................................................
......................................................^.^.^.^...^.^.....^.^.^.^.^...^.^......................................................
.............................................................................................................................................
.....................................................^.^.^.^.^.^.^.....^.....^...^.^.^.^.....................................................
.............................................................................................................................................
....................................................^.^...^.^.......^.^.^.......^...^.^.^....................................................
.............................................................................................................................................
...................................................^...^.^...^...^.^.^.^.^...^...^.^.....^...................................................
.............................................................................................................................................
..................................................^.....^...^.^.^.....^...^.^...^.......^.^..................................................
.............................................................................................................................................
.................................................^.^.^.^.^.^.^.^...^.^.^.^.^.....^.^...^.^.^.................................................
.............................................................................................................................................
................................................^.^...^.^.....^.^.....^...^.^.^.....^.^...^.^................................................
.............................................................................................................................................
...............................................^.........^.^.^.^.^.^.^.^...^.^.^.^...........^...............................................
.............................................................................................................................................
..............................................^.^.......^...^...^...^...^.^.^.^.^.^.^.^.^.^.^.^..............................................
.............................................................................................................................................
.............................................^.........^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^.^.^.^.............................................
.............................................................................................................................................
............................................^.^...^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^............................................
.............................................................................................................................................
...........................................^.^.^.^...^.^.^.^.^.^.....^.^.^.^.^.^.^...^.^.^.^.^...^...........................................
.............................................................................................................................................
..........................................^.....^.^.......^.^.^.^.^.^.^.....^.^.^.^.....^.^.^.^.^.^..........................................
.............................................................................................................................................
.........................................^.....^.^.^.^.^.^.^...^.^.^.....^.....^.^.....^.^.......^.^.........................................
.............................................................................................................................................
........................................^.^...^.^.^.^...^...^.^.^.^.^...^.^.^.^...^.....^.^.^...^...^........................................
.............................................................................................................................................
.......................................^.^.^.^.^.......^...^.^.^.^...^...^.^.^...^...^.^.^...........^.......................................
.............................................................................................................................................
......................................^.^...^.^.^.^...^...^.^.^.........^.^.^.^...^.^.^.^...^...^.....^......................................
.............................................................................................................................................
.....................................^.........^.^.^.^.^.^...^.........^.^.^.^.^.^.^.^.^...^.^.^...^...^.....................................
.............................................................................................................................................
....................................^.^.^...^.^.^.....^.^.^.^.^.....^.^.^...^...^...^.^.^.^...^...^...^.^....................................
.............................................................................................................................................
...................................^...^.^.^.^.^...^...^...^...^.^.^.^.^...^.^.^...^...^.^.^.........^.^.^...................................
.............................................................................................................................................
..................................^.^.^.^...^.^.....^.^.^.^.^...^...^.^.^.^.....^...^...^.^...^.^...^.^...^..................................
.............................................................................................................................................
.................................^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.......^...^.^.^.......^...^.^.^.^.^.^.^.^.................................
.............................................................................................................................................
................................^.^.^...^.^...^.^...^.^.^.^...^.^...^.^.^.^.....^.....^.^.^.^.^.......^...^.^................................
.............................................................................................................................................
...............................^.^.^...^.^.^...^.^.^.^.^.^.....^.^.^.^...^.^.^.^.^.^.^.....^.^.^.^.....^.....^...............................
.............................................................................................................................................
..............................^.^...^.^.^.^.^.^...^.^.^.^...^.^.^...^.^...^.^...^.^.^.^...^.^.....^.^.^.....^.^..............................
.............................................................................................................................................
.............................^.^.^.^.^...^.^.^.^.^...^...^.^.^.^.^.........^.^.^...^.^...^.^...^.^.^...^...^.^.^.............................
.............................................................................................................................................
............................^...^.^...^.^...^.^.^.^...^.^.^.^.^...^.^.......^.^.^.^...^.^...^.^.^...^.^.........^............................
.............................................................................................................................................
...........................^.^.^...^.^.^.^...^.^.^.....^.^.^.^.......^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^...........................
.............................................................................................................................................
..........................^.^...^...^.^.^...^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^.^.^...^...^.^.^.^...^.^.^.^.^...^.^..........................
.............................................................................................................................................
.........................^.^.^...^.^.^...^.^.^.^.....^.^...^...^.^...^.^.....^...^.^.^.^.^.^.^.....^.^.^.......^...^.........................
.............................................................................................................................................
........................^...^.^.^.^.^.^...^.^...^.^...^.^.........^.^.....^.^.^...........^...^.^.^.^...^.^.^.^.^.^.^........................
.............................................................................................................................................
.......................^.^.^.....^.^.^.....^.^.^.^.^.^...^.^.^...^.^.^.^.^...^.....^.^...^.^.^...^.^.^.^...^.^.^.^.^.^.......................
.............................................................................................................................................
......................^.^.^.^.^.^...^...^.^.......^...^.^...^.^...^.^.^.^.^.^.^...^.....^...^...^...^.^...^.^...^.^.^.^......................
.............................................................................................................................................
.....................^.^...^.^.^.^.^...^.^.^...^.^.^.^...^...^.^.^...^.....^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^...^.^.^.....................
.............................................................................................................................................
....................^...^.^.^.^.^.....^.^.^.......^.^.^.^.^.^.^.^.......^...^...^.^.....^.....^...^.^...^.^.^.^.^.^.^...^....................
.............................................................................................................................................
...................^.^...^.^.^.^.^.^.^.^.............^.........^.^.^...^...^...^.^.........^.^.....^.^...^.....^.^.^.^...^...................
.............................................................................................................................................
..................^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.....^...^.^.^.^.........^.^...^...^.^.......^.....^.^.^.....^.^...^..................
.............................................................................................................................................
.................^.^.^...^...^.^.^.^.^.^.^.^.^.^...^...^.^...^.^.^.^...^.^.^.^.^.^.^...^.^.......^.^...^.^.........^...^.^.^.................
.............................................................................................................................................
................^.^.^.....^...^.^...^.^.^.^.^.^...^.^...^.^.^.^.^.^.....^.^.^.^.^.....^...^.....^.^.^.....^.^.^.^.^...^.^...^................
.............................................................................................................................................
...............^.^.....^.^...^...^...^.^.^.......^...^.^...^.^.^...^.^.^.......^.^...^.^.^...^...^.^.....^...^...^.^.....^...^...............
.............................................................................................................................................
..............^.^.^.....^.^.^.^.^...^...^.^...^...^.^.^.....^...^.^.^.^.^...^.^.^.^.......^.^.....^...^.^...^.^.^...^.^.^...^.^..............
.............................................................................................................................................
.............^.^.^.^.^.....^.^...^.^...^...^.^.^...^.^.^...^...^.^.^.^.^...^.^.^.^.^.^.^.^...^.^.^.^.^...^...^.^.^.^...^.....^.^.............
.............................................................................................................................................
............^.^.^...^.......^.^...^.^.^.......^.^...^.^.^...^.^.^...........^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.......^.^.^.^.^.^.^.^............
.............................................................................................................................................
...........^.....^.^...^...^.^...^...^...^.^.^...^...^...^.^.^...^.....^...^...^...^.....^...^.....^.^.^...^.^.^...^.^...^.^.^.^.^...........
.............................................................................................................................................
..........^.^.^.^.^.......^.^.^.^.^.^.....^.....^.^...^.^.^...^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^...^.^.....^...^.^.^..........
.............................................................................................................................................
.........^...^.^.^...^.^.^.^.^.....^...^...^.^.^...^.^.^...^...^.^.^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^...^.....^.^.^.......^.^.^.^.........
.............................................................................................................................................
........^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.......^.^.^.^.^.^.^...^.^.^.....^...^.^.....^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^........
.............................................................................................................................................
.......^.^.......^.^.^.^.^.^.^...^.^.^.^.......^.....^...^.^.^.^.^.^.^.^...^.^...^...^.^.....^.^.....^...^.^.......^...^.^.^.^.^.^...^.......
.............................................................................................................................................
......^.^...^...^.^.^...^...^.^.^.^.^.^...^.^...^.....^.^.^.^.......^...^...^.^.....^.^.^.....^.^...^.^.....^.^.^.^.^.....^.....^.....^......
.............................................................................................................................................
.....^.^.^.^.....^.^.^.^.^.^.^...^.^.....^.^.^.....^.^.........^.^...^.^.....^...^.^.^.^.^.......^.^.....^.....^.^.^.^.^.^.^.....^.^...^.....
.............................................................................................................................................
....^...^.....^.^...^...^.^.^.........^.^.^.^.^.^.^.^.^.^.^.^...^.^.....^.....^.^.^.....^.^.^.^.^.^.....^.^.^.^.^...^.^.^.^...^.^.^.^...^....
.............................................................................................................................................
...^.....^.^.^.^...^.^.^.^.^.^.^...^.^.......^.^...^...^.^...^.^.^.......^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.....^.^.^.^.^...^.^.^...^.^.^.^...
.............................................................................................................................................
..^.^.^.^...^.^.^.^.^...^.^.^.^.....^.^...^...^.^.^.^.....^.^.^.....^.^...^.^.^...^.^.^.........^.........................^.^.^.^.^.^...^.^..
.............................................................................................................................................
.^.^.....^.^.^.^.^.^.^...^.^.^...^.^...^.^.^.^...^.....^.^...^.^...^.^.^.^.....^...^.^...^...^.^.^.....^.^...^.^...^...^.^.^.^.^.^.^...^.^.^.
.............................................................................................................................................

5
README.md Normal file
View File

@@ -0,0 +1,5 @@
# My AoC-2025 participation!
each day in the respectively numbered folder.
some of them are probably decent, most are likely not :P