Skip to content

Commit 0174663

Browse files
committedDec 8, 2022
first challenges
0 parents  commit 0174663

File tree

6 files changed

+1280
-0
lines changed

6 files changed

+1280
-0
lines changed
 

‎.vscode/launch.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Aktuelle Datei",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal",
13+
"justMyCode": true,
14+
"cwd": "${fileDirname}"
15+
}
16+
]
17+
}

‎day7/dirInputParser.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import re
2+
3+
class Directory:
4+
def __init__(self, name, files=[], directories=[]):
5+
self.name: str = name
6+
self.files: File[int] = files
7+
self.directories: Directory[str]= directories
8+
9+
class File:
10+
def __init__(self, name, size):
11+
self.name: str = name
12+
self.size: int = size
13+
14+
class FileSystemPointer:
15+
def __init__(self, currDirectory):
16+
self.currDirectory: str = currDirectory
17+
18+
# testFile = File("myFiles1", 33232)
19+
# testDir3 = Directory( "myName3", testFile )
20+
# testDir2 = Directory( "myName2", testFile,testDir3)
21+
# testDir1 = Directory( "myName1", testFile, testDir2)
22+
# testDir1_1 = Directory( "myName1", testFile, testDir2)
23+
# testDir = Directory( "myName", testFile, {testDir1.name: testDir1, testDir1_1.name: testDir1_1})
24+
25+
# print(testDir.directories[testDir1.name].name)
26+
27+
file1 = open('input.txt', 'r')
28+
29+
lines = file1.readlines()
30+
for line in lines:
31+
print(line)
32+
if(re.match("^\$ cd ([a-zA-Z0-9]{1,}|[\/])$", line)):
33+
currDir = Directory(line.split("$ cd ")[1])
34+
if(re.match("^dir", line)):
35+
currDir.directories.append({line.split("dir ")[1]: Directory(line.split("dir ")[1])})
36+
if(re.match("^[0-9]{1,}", line)):
37+
currDir.files.append(File(line.split(" ")[1], line.split(" ")[0]))
38+
39+
if(re.match("^\$ cd ..", line)):
40+
currDir = currDir.directories[line.split("$ cd ")[1]]
41+
42+
print(fileSystem)
43+
44+
45+
46+
47+
48+

‎day7/input.txt

+1,032
Large diffs are not rendered by default.

‎day8/code.py

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import numpy as np
2+
import os
3+
from enum import Enum
4+
5+
class postition(Enum):
6+
left = "left"
7+
right = "right"
8+
top = "top"
9+
bottom = "bottom"
10+
11+
class Tree:
12+
def __init__(self, height, marker: bool = False) -> None:
13+
self.height: int = height
14+
self.marker: bool = marker
15+
def markTree(self):
16+
self.marker = True
17+
def getHeight(self):
18+
return self.height
19+
class Forest:
20+
def __init__(self,maxSizeX,maxSizeY) -> None:
21+
self.forest: Tree[int][int] = [[0 for _ in range(maxSizeX)] for _ in range(maxSizeY)]
22+
def plantTree(self,tree: Tree, posX: int, posY: int):
23+
self.forest[posX][posY] = tree
24+
def printForest(self):
25+
print(np.matrix(self.forest))
26+
27+
class ParserToForest:
28+
def __init__(self, filename: str) -> None:
29+
self.filename = filename
30+
def getForest(self):
31+
row: int = 0
32+
col: int = 0
33+
forest: Forest = Forest(6,6)
34+
with open(self.filename) as fileobj:
35+
for line in fileobj:
36+
for ch in line:
37+
forest.plantTree(Tree(ch),col,row)
38+
col += 1
39+
row += 1
40+
col = 0
41+
return forest
42+
43+
class Lookout:
44+
def __init__(self, forest: Forest, pos: postition) -> None:
45+
self.forest = forest.forest
46+
self.pos = pos
47+
48+
def getObservableTrees(self):
49+
highestMeasure: int = -1
50+
for x in range(len(self.forest[0])):
51+
if int(self.forest[x][0].getHeight()) > highestMeasure:
52+
highestMeasure = int(self.forest[x][0].getHeight())
53+
print(highestMeasure)
54+
55+
56+
def test():
57+
unoTree = Tree(1)
58+
dosTree = Tree(2)
59+
tresTree = Tree(3)
60+
quatroTree = Tree(4)
61+
cincoTree = Tree(5)
62+
63+
myForest = Forest(10,10)
64+
myForest.plantTree(unoTree, 1,3)
65+
myForest.plantTree(dosTree, 1,5)
66+
myForest.plantTree(tresTree, 1,3)
67+
myForest.plantTree(quatroTree, 1,3)
68+
69+
# test()
70+
myParser = ParserToForest("./example_input.txt")
71+
myForest = myParser.getForest()
72+
myForest.printForest()
73+
myLookout = Lookout(myForest, "left")
74+
myLookout.getObservableTrees()
75+
76+
77+
78+
79+

‎day8/example_input.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
30373
2+
25512
3+
65332
4+
33549
5+
35390

‎day8/input.txt

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
100021112110202312022010330204312040000111012143445142221414240220240442332040010320133120230011020
2+
111110201332323210211143123214321343332124211413115514155115511033421001222101204330001300333011010
3+
222100123300231230122203432310224441551434231352112532354252244334410042212441233243220102033110020
4+
212210311310102334321243104133012535144151532555155341325352512544453402400411340202133231000102020
5+
112002102322001003304233302040124544411225523533534235113353522233535550432232202401221022110311110
6+
112102131331201432320312233124434232544144233241123334112232531521542551332434224211234133132330300
7+
201212231001314001232020011521543445152251413225334151155332443144315433444321403022301110231133320
8+
222200212012234021440323522251222114255435321245463652634454445441313331334221403314121340322201323
9+
011101313030124034011053132411352313135432265223564644563435541314314453511355132441242220212301210
10+
330120320004414224001225342325133541125622665563263444434232635442123423514224513321324324321221201
11+
232201002203142013213541415521331136252365342544552365442625322555515234315251334143110114433011330
12+
231032032133203330135134524113312353466322543643543364665636365344645123214255433423420443411102113
13+
323210134414131324325554245224653435365453364456243243426526432462344551442433224554110342343103002
14+
232211304402432454533435252145662665532355636326423563423433555236565455345421453313301243030201033
15+
301334404444113432444154526622565534622453452465656373363346236352264432242255511441531301201430310
16+
021031402014322514331554342423522244643245347463537353546733344353665264632651255422445201241324231
17+
311341433423143525332424243226653324554455444337664375746566644363342254524365544454512533412221003
18+
100141044421132331524146432626626222746377344775337675474374667736346526345525531112515524220332342
19+
103100424013355243423532363653563355763646667345657754366374646535626642326366655331552511413232033
20+
010411402325242212332662662566365363733444434344454736635435565544436445432562223352255125432214413
21+
321313023231141232536442263534773775537454346454663656656365364557334363362446463531553445101214414
22+
240014233445325423455462553425364653653645333436556455474746633767756644256625645261111551134401102
23+
141243103121441452453322334274356634453674654475774776665766755335473637655355324552442441555404422
24+
322032122454423446326624652657555775743558467874777864887767556333635645342466232542452344223021030
25+
341012035442545266666542455563533577735885866784868684486868864657367574557543634634445432352101333
26+
020332133545225646653645453347737756754567886778577468644476777475537454454734354466644222142343014
27+
443312425144123235564325363434377486685588484488457888748854756668646745465366635445226143535350403
28+
401011343544455465645234773757567857786858744667847887678865684557657673336765353252254124535144301
29+
231023111541232646654364676655554478448887447788656586858686874555544756355355425663634445444231041
30+
440414511232163335524763454743366676656778445597669969755446578885785477433565366464462411314121213
31+
423133115311242232226334356676577546867445799868866958556677644564858573537455653355226445155233301
32+
203312245131462222554746646746567788757698759759588997656957785788856475653644633464554355125443503
33+
232515114525335654457543443555565868786576595878575876598966858547666846455373765745424444124453521
34+
222335423146245553644554757748846867467979895568976578965955877985885478853344575356225432342255433
35+
101542414345642523353567565774687668996586857857667878786879985798875768547745643456564266313332224
36+
301144344462663436337536345845856858757875777768966787979577767876448646654465333646326566332352143
37+
421524351232465434654576565767446575666755968687986969675676875569846488676754753357442332442433411
38+
413325242333454424656334665558754657887868888788696877986559786689587455864465343775662452632451433
39+
154244543442464674633346657856868997877985698877867876966997859957879646664844343364323322443522435
40+
413112322322235675547345547474859589658598796866669766699978589785866454757775477664523433333434442
41+
424333122434626456777635768578686868759696687688967977688996678795685586557475554454652235566333123
42+
455211225265424477347444685544699887876977897876978778998988685797998647458856773634522525443114455
43+
215254146366363747473755887445877868656789966766676898799688786567569855574684673733533243626145254
44+
232214336435344464337365855745665767968888669969788898668797767777899554757865644635655552352235241
45+
431445513242642634373387444466656585686776979787998778778876688797776987575785547434636436252135425
46+
341254135453625764555454784558697758996768789898879887979776988667895866467544537467352465554231341
47+
353511356522232754333665846875756885597979987979797998788867898755966966747777863335465653622312521
48+
342131425455252547374557454676889585769899979877988878787678998666857676478654857544553344324545533
49+
423514554622265364535758656757779586677868668897789789888887987885766775484647466733766544444641311
50+
443223335562467674644684785459675797877798787899879888997799677698799557567657744564575455564221324
51+
434334525556625335565445744449679766879887898799888779777969797666677897876666577353534665444633525
52+
254452226436653735365676845666667659869878998777989789787868689999995856864675465356773254455643433
53+
541343235664626453454454858567778559888976667877797788989989978879887596787865646354356245342421323
54+
522412226622325753744545556855766985687768979797897799987698989897779696765756544634672555453353213
55+
412522254444564635737677845545956698889698677889799979989779898956976777758878537634642425526241551
56+
454222136263222765655775647779568866577886976888987989877869678975585697848476455557545354635351442
57+
135121552535465363736474668878979599679996967978778988767779668655599557568578867666446332363541241
58+
443121425555335774663648754687768668779998779886677866797868896598977975744577757466744252426313232
59+
413544235544623474445636785886865856978977898886979867667687979665559785856884354355373456533433444
60+
131513455323433453365575445468776665975667767679666666676699795889878855677784375677726235226322425
61+
434442215625364456464667564866697986985698768698867797888969976976557974477456645553454563433515241
62+
453531215644623547465376468645845588955556796689667796966679798897589845547855353757662556342441532
63+
332355435635654445755366546668857777995897877866676989779679698556675648665863767454324443235151225
64+
213534313254232564576535444544764898568875856676999867867657557989768547684445736355423244324413543
65+
124522522235244346567747584544557769579796878589766996768788685995875444645835373437362355652144245
66+
442414332462645464457376647585848848965577665855857885698768798696575546674475573646566222314114445
67+
112315233256652343737667637858458576968777559868597579967759677588458846648655454334245245345554224
68+
130224422112546654465464363764457446579885795857586579789779888566478866866743355335226264212535322
69+
243155553555342624676436455375874765489687699588798796759766675675567774646753634355346454424431253
70+
313442313423322535325375377344687658457576699776856776787599774474677575337743334422233423431421211
71+
234051131411522623337474757677857685464857596667557579666787555744487574544673364663643435211255240
72+
434314134422524322443747337633658574444468845599797888867456487676744754336473656352235344411242110
73+
004101145215335222325475546343745855484848877575546845867885845455746457433457436466565332352124123
74+
233441434144112564624645544646557557655667845446677675588784866645475343643574552243656523444534030
75+
121224143555135555564544776734555455674556575754675486888465845458835743367333425354526331434444031
76+
421244422344321446364634257366433445747885577774664546565647578767333446746356442243433411415210430
77+
134214243522231144462465353566577763536746478855876848468846687644663756364224224464635451234214111
78+
141132203421215213235464224663666433534678865566554887458784575743373335336464662256425123321434014
79+
213231333411351412344352524277763665543774674775545875744754576367464737663564262663112544415131113
80+
310320312444245332353443555344534456457456364753657473447435543364646364264425336635335354223233231
81+
314242332123434345266456226225367677737356563336765735555554546764556543652364555632435415411342334
82+
220144410231433531546232424625336566373376474676454647665666437455766323355345563421345422444413112
83+
331442434421142252212466563352266545334633374637735376643435675553544366564244525132151223011342202
84+
203334211344322333542433654434655335633734475664756747766375655456225622225333343324215521200001401
85+
133001044130025211433335626552525266367334377736466473364444543236446653253662222322415412004404203
86+
102331031201225135443424246553365346664536353367434546473743334356454654552233145534345231113214102
87+
212230010342131553532451526322255666663223366332674653633446456525262543246511312215123143100414322
88+
232101044243441133154151523542336655464563325444436323646534526542245542613552531321441404211220231
89+
230210113134231442312133523231426423645562233522662322645556325555424565225553133115020231142422303
90+
112122132434123424454552435541116536436354343364366253452343245526436543253435122423041022130131032
91+
303333011024122011435455241134321332555664352652523256255643224225644425233221344014220444400330023
92+
103302231310301313234354141312323434532246526636322542364336342533331445554253314030214223423211003
93+
110123122321424301403345325425115544551445462636362336444425435312233541552212143231043320211100213
94+
202211312210402020033410432324431253144325523235463625332451131521414414333322211144344230221323102
95+
210100112030114430323324002554125435321123334342551235451453442512153411112423411424123322300320102
96+
202220203220032000004314434423331253245534454123425114423553133414151232240304414101402311330002020
97+
012211131001201000134433142021511253314413353152553443443342425435421132024242024214322330313300110
98+
200011111022120322143342040443334552235435211511231451452222252222113214233002413424112001211130112
99+
202000213331311222142203242110321123234552545321425122145424451321304200332123042013120323022211012

0 commit comments

Comments
 (0)
Please sign in to comment.