Compare commits

..

10 Commits

Author SHA1 Message Date
David Gailleton
b079599443 07 bonus 2025-12-17 17:41:39 +01:00
David Gailleton
3b878c0bd0 07 2025-12-17 15:30:28 +01:00
David Gailleton
e3a675e1b7 06 bonus 2025-12-17 14:57:38 +01:00
David Gailleton
a8d46e5747 06 bonus 2025-12-16 20:30:23 +01:00
David Gailleton
79cecd7d27 06 2025-12-16 16:51:12 +01:00
David Gailleton
a11db9327e 05 bonus 2025-12-16 15:25:34 +01:00
David Gailleton
0a617cc507 05 2025-12-16 10:57:14 +01:00
David Gailleton
63bb1bc416 04 bonus 2025-12-16 10:25:17 +01:00
David Gailleton
aac8832df3 04 2025-12-15 16:06:03 +01:00
David Gailleton
ea1cd04500 03 Bonus done 2025-12-08 12:56:39 +01:00
35 changed files with 4626 additions and 3 deletions

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/07 12:53:07 by dgaillet #+# #+# */ /* Created: 2025/12/07 12:53:07 by dgaillet #+# #+# */
/* Updated: 2025/12/07 17:43:45 by dgaillet ### ########lyon.fr */ /* Updated: 2025/12/08 11:08:38 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -38,7 +38,7 @@ int main(void)
first = temp; first = temp;
while (temp[i + 2]) while (temp[i + 2])
{ {
if ((temp[i] - '0') > (first[0] - '0')) if (temp[i] > first[0])
first = &temp[i]; first = &temp[i];
i++; i++;
} }
@@ -46,7 +46,7 @@ int main(void)
second = first + 1; second = first + 1;
while (first[i + 1]) while (first[i + 1])
{ {
if ((first[i] - '0') > (second[i] - '0')) if (first[i] > second[0])
second = &first[i]; second = &first[i];
i++; i++;
} }

200
03_b/input Normal file
View File

@@ -0,0 +1,200 @@
2213322222223222132231233322432224423222226232323522232215252332221122222231232224232722131522422232
9869755494885236452767647548826258555668838497687557968652485746757835445145546687436356799481798587
1333642233323333373233223535543332333343733333323333333333315334333323343343333333332321233332333333
2412331232332223332211413223433332213222252142221323322122212223222321231322513323122332321233233222
7233333554333634354333355353442655334523373532334435335733343124433353732333236335456441345343535443
2542623755573343945454412366525442424744334132133146357442166333737542732631343535567546644733453327
3223423125721322245221313311333222222222322321672232321322215121332232323522331112523842131211222231
1341524443834221222553325236443534253327533543493534348242333119334424249244524325448544522322512344
2122222234421423322222232231221455261322312321232223321232322112233222233223322222121221322232225222
2172228252452422574523272252246532513514251543422251252233622213162235313243341322723224223472223342
4333333322374312333333442252233332323343236421333332132232233523333223643444244332233333333314343374
5564564445425635543326425252871657266475435535644335444428545455444345414454654413464444444543452332
7454483454246843436686564547347643444463364743844643844454433455547944454424656442455444258453453949
3545239364734434356884585159793673287754643667512332857278643456465359873642643268698837552366444279
2222614212122412212232521222222222322162224122212255224652222252322242352254132522221123221222222222
4654734524468553536655551947342343744798353537531365525555255373383337465222438553556563343546674795
4223343232434234223443433132443232333433233241333323334444234334443434435341513522333132223342423334
2434743225152133244934233332223333342332742413225323434322133133342225263461325222442331344323333621
4363333625436326121432327152115232112437232426739557622735333213153454854223553223332333163322332262
3291224524551531661124222122232433443332372352223452323152254212524224475353217335338132112225138382
2532334224334412444233531343333232434672372334424223232433234233235242243334444434532142565432224543
6575467444354636644724356545439443727633232211663455734655446347433346552413539455535454456546344467
2212123522212256112142223212223223926221423333322111142121322246521222623231121222222233122682282232
2427422153354454221223483334425221233131444333342323144413423342141422222343422242225233412322852334
2223222262222351122221222542222356232422221312224223222121224242221142612223533222222326212112222231
1122221221423121122222221122242426222322222218222222222122222424232223133224227122232222225212322431
2223225222263221223122232222231322132249422122222222212343223233221231112333321122224822122212112221
2234133242122472222333323231152222313322242231321234122233314332232125212342222222141222224223222243
3222421121132228332482223722323212227931233222232311122728212342422323911121332241322122212225222224
3342221445144453253254314734532247546356242543223144334535244724343441632342442234353332554531544544
6644254436227552262158566262526533915631231552333722416565536354544652263755643341664563253253335325
2212221212221266252415512232524121224221462212225225525255242115212235231241252544312222525112533222
1212222242222222122121231123212212232222221112225222122222212212222222222322221222222333222222232121
8437515934322544325244332733235426312213422543233274311523432242324234425333225643164333335325158723
4955559385766953565255766876476558356667683243721462495465455956585541549636358359356553352726754357
2321212231311222332231233622451222223233632131325333155422313242233246235373323463222222233151352225
5554455544442245353244364445444442964455743554423443344234626245334485444521454444353644544434348444
3584546435435438362463553335553744339333343334752434593543434442333333333374362737434422835322244974
2224322223132222332322223422213222223821212223222243223232222232232222362222323122422922222223222321
7532213233323334215212222423122123222322425222323732234174212342242222239222238232423135916233324313
4725333553331231732334534535433413336333334433335633862233333333343434333253574633253313333533322533
2222122222233222222212322321212122221322122123122322232112231321222234222233122122113113222142221222
7618667762444757529352444283355721866946122758937266864545275866446765437263255944277544354266743555
8775885395735793768798676737467545866325994734656888365669834844567693699478564767598836687838775796
2323222163231422333232265212225222433552125522231421223232222242111255222111234232222234643453222212
3212222223211242222322222423924221333231242222215221222222222412222332242222342226222112342222222423
2312517442152222775232225322152322134642256726212312232253122631232442222322774322261522237322225221
1412232232122132322214222245123232224232423122523323323512434322222122322223232324512223213223221225
4624745444557739264643334474753442344576454464364444542355443444953574753765466446534445555247546645
4444445543553433353354455144453453542444435444454565454246452554274346433345434464454144453534444454
5222221211223232461222322221422324122212222121524122122224222221222226222282222211433212232262313272
4443424217342232322234144234322244432422332123432122562423442343241152444222734444343343324245233331
4625363444334325314433134332342626273324257534444232232533221335211222233354622142319633834554323252
6411222232214222222522522212115422324312321212512352222222222521221222222422213215222323222542332225
4443435744444443443454344444553646453444473243634337443343333445443444444444544642353434424344143344
4222322212142222131123232424122212623122325223232222122222324172123313113213221112221214131212326232
3628228272226822792212222291522222262281252222222122523312222224388323226222431232246223822272242222
6452232522272722232314236322514222212124422122363122133442752472323254631272561324232244232223412433
2232232212252263221723231243261132732225353342123222262123232223621135231232353226314132222321322523
2234532142534352552432224445238325213424373452334233522333242532331322332283352427475226322153223244
9472212243122222252422922222363422333321126243222123963224222212173222233224252234412121222122821213
8687898777877956884675896696763989727598788596888366975787785653266667396852928885385879777658746578
4742438327346661542272567435214432666247432532364464374423432252594887642242783264284248334549366538
2843543444552553332333549456453152452655123452245534625343434434394353525145545815233325253353558525
3244334344333322333336326524543522543353334524333542335243334463433424253344265152434334435422433433
5123213122132653223552342918633223322124141221532722222222633832112321232362321212223224311252232323
2254522224536212312521242224331285151323234522312332222153222222233213252422324212324255413222233635
6932637327758743246546437713551343621222422345652667325366263533277364672223242653614462113113621452
2664332353263783333136373783525676334732434213262462433235335292339233763346833362333754633332336332
1223222424223252223213121222322322216422412224222612422223221222312122222125212222415122232226422521
3542584332435333333233354353545344224553534123354453332523352334552335453523343512333213234387634133
6477957673773844477447976677777779677788757572445797735766653875666759654537677675353627655576767927
2122863223233922223222231121222335332223122512323122233223421212114232222322232221223392322222521322
4312524534123246451432343643224311242447241134644264223443332245433262232641376442432172472222642235
2275325124326274246343242342674425241126422624221639763313155173323211554216434553212654542522244512
1538376354635334634345152866523443431672342341845227336436433755352916223414454255126676464326465453
2462132262212214732224191166344355414456333232523325425323262172634333344212243223136153134622523124
2631319623233673572328447522142326723725312315363222557334327382237347133534333342445538226351733877
6674525765645736755277426478666374433478565771746335482576661384446336527753576379765114777324835247
1445214354534443124443143152322124342543358432243223532332224344453244325421233463452464443336435444
3723543344762463142452771243123333533262534743357433433442333434323237223413433322343122246434425297
2522212232142222322222221222222123222513232222522212222241212423221222221232222422123182421222222352
4649425575652455655345524446535555664456453353551334555552535554525353745544253454663345473375355545
2634673446446644485645555244654443495523355587664334545525752374784735443457755455456485493456463553
2242233312853232212222233154124241433323223342432114322372333333333232333133312323424253242333222527
2252222222122622131222221211221252222222262122342222322122323222252212223225224113322222213227122112
7145153421321212213232213242421325372523143232242542622222334162232643213463222315224332241623233632
3324124233321322222222324392322321322222222224223432342142234421321364212212331212326242323313313333
2472266245644522634774327358522262635513323335182372254462662143946277975225436422277562365266655423
3454443243442454643335544534416344433344445654442214445434214514463442433444324544444345444345543344
4367979552245565165576424776225962637573364823785465568368636312742298786276647827575676469244525653
3225626443313133323723323323333314253554364347343365333323333336333733232322233333323433327322332332
2573343343233434433434335363345452556353493431488327365413335557454378339752343364644435453325754543
3332172133227223334324253377332133233323223333532233333322112735223232322223234272123323333632212223
3454534475343444535444424745434444444344455444623375454534443434344544444438232474343544535454434444
2644342235344483342633422636454456365233515643444645826444442446956214445156322264445433443453544256
2223435334423434443323343432344434441333333333334433523433332124432343243433314444324423343343444233
3212252222442321323221225293213122528329522211182223418222232142225234221221222222423222321246232122
4353432493542334325235547332734383332234542144323893258347384435444429271453353353448434142247423122
8337935245577558348845559668464454534353766484438335543755757443777274244484345834388345496944455467
3443463333334453433232243443222334133233433234432324222432323533323324433242132332332124242343233322
1435542554154543564533441335544555244531645445572234345443345431434433534143565444437433564233354423
3333312334342233331223233234233423333333333222332233423337233233333323213132222322314332323333244443
3144453439443334333662444343463453336433435352354493435346436453383544432444466337453337853423233436
2621273163344422333343232136211636224222434231116342222542232213433324642324241176224342723221422332
3233236263233353563335231233252323223521334126123623332512327322312223333223215221283522467362232326
2232223222222222223224222222222221221211221222123322422321223212222221322222212221222221222222342222
4443435431454234435334436543423453441422434424434246438432132274643321323342524533232532212314424334
3434222234424123524222452333431221233121324331412242454221434433122432415442443243322313221343241245
2321552222525121432422322331221528511324222222222223251323221222325322125252122222212222223233125422
2113322212122312221212122222122232221222332422312233422223123112132122232232231222235122334122222212
3732434222332433314434542433334343433225344323314343343423334323322433232435323333324234332413313341
2243352221342443222271236434365322934422234223125222337624122643272322622437441322243413243473882412
2527574826427351353683632227267232139241272336778354926836323453363482545233625417243233594635373371
2352124323843333323253365635322233542433122438331432234333233233552321434213213222343343494522232371
1322321231222372222321132512312222322322224462222223322222222221223222233121722212522142211233221233
5444455244355434653244514353733425555432435524445462355644544453443433445226446336553853553454444444
3332233333334338391321272312134322233863322333432334333383232342334223332333234786233333432424325933
1423223524424321433522322244232223331233231333313336222333934223422133232353433212332232224322322433
3846414434329535333324434434463744365584534935533343538345434362733943434244645366346976364533243345
4643437654442357354452643453433595563365355434644545556753685648354446745633345454324745655324554344
2131424213433334334241312123344324133131413343442431244222441243341422141411322341334123242221356789
7416322321423422532433252263461535237341336423224758925417544133763249354532465584557477436637134868
3532232342543633244356234447125413363324323324222289345334243223343344349423623323132345434545334456
2222222223122224523322222414412221222312521311252212471135216121622212122422823223224222252322223322
6844572852724766364376246428458471423425425655656355452483274422366737555436524246373644225524226684
3242324353115355355323223333323433133532332325223553622433333532532333223134223363333333733357422553
3626353353644274241533142456273326314323662575363324353232556433624425644535422316323346623244545532
2724454534154225253459433524763422545426423332642224232423242219414234215362382511227546231223755232
7442133222243344231433423324322522433233342443244242433423242443424324213224132442463664334134342334
3463633243546333375266535312435244564434333724665664625374363683533955743535443448446155363433352435
2264222222213232253131424222232214292212282234282122225323422451223621252222122222122222532326531252
7615864866564643665565345652664464866686665436644563376466655765566766633576745646454764727756626448
3232682631537442445212595232662334363343227323835122465351345356353233643332543416323346345346643365
2477354147362541612246656262342473335717542264534245221467537422444573332674431531423425215312544289
2334432533153324242344341754352431132342242483614364474473434824424423481248441342313143738143793223
2453444254242142424354527214334534514423135772455224332544144347235744422234224425443544453243344614
5212223252122422331232123222142312233422245334462222222225244224221242232221512243232224234433555222
4663361654535434444435333426543336213653424435533654435334427263236324336542736224533733545413433239
3363338333145338474323437333462332324223453341452444327323423238343353864322373218432131334133331333
6252146332321485753632148626252215423622661447732432532425663473353884553422633662223652246821433466
6323212434222112525725474243264325545472241252227222635137276274422143227243432646722261633476517122
2292128532222284521512222622221222422421324224222681233623522223223262427233231272222123235231221181
4286246955215254312515631624225942342242521826335223234535339245216232525515324431229213242425522424
2622122232123521122122322223322225522212213235316222222233213212622122172232222411222222312122211732
2392322272325242232246227222232731732621613276422282332227135645532724216422152724335327741242231462
2133344331342334353334326416233445424328334428226343632383533126256345224276253624433232223322429335
1313445155233335142345133432424315243344534322414122115152312323134555232124514425531444334531116789
2176422423121432443422442232123322224224142721224212222312511322231432233234223323244211222332222122
1323212331222132233231423322222222214333233212344223434312442222492221354321222342223332373533322621
4664434362444745561444535453345435524434346435454274864444654324476633565349444454455353443364156363
1638584275546117346163717254773527552852888544638242767347444874466266733617618166164466374362765419
6484454656734464566656446354242553953738747675494353263545534655932284732414565465456217445446466422
3485414422321524833475231333422824247332244623522414142222262253355414452434234344554242224422224624
2333263233433521134582215333224332925436375333333336732316531375333522444212233753383365335354643243
2322132222223221323111333232222233332322122232221312232253222222232322332431323222322231242312325223
5335322444334334442443232426223323234447129221322222234335221422223321222322222324423233342232233364
2233232223252234233222422323332233122122213133422132233223243122322122142422223322242222332521212211
2243222246232222212215234223244341293823233413422262122231434142334224211122243244723212111327343722
3313433324333323233333323332233423333523353312313633334213233333425232634123313333625322322224342122
2223221221321122424222323113232211222413233225122222222312222222225361224122154344233232252313223232
6426445154869355363363722336455335472343572534323456253645532493615956527636643453556642545246266326
4342252241221222341214232232226432422223222214311224253224847131242221312222431142152243223533228364
3122222221312333212221331241133322212322122433312122322332322212332222212322222142232224224432241333
4758777554587868737644678898656677787655757385768789874455858856835848887478458889776575587488744887
2222222322222222132444434221222223222211212222421221422124222221223422331422622421122212232221222222
5543453232434923234235323433433652346343532235133533353325643323414321344433315332531344244423332533
1422222221222222212122311222212124122222322232222122112222222222122221212242222322212222211512242221
5624318328343613762342133122287362233222333228233526432235723228212317225232222321322843831822233343
4745555462555745374333447645563565846565658565674475358542453455774373535925543556456253364455655565
2231323341221332332231232222211222122232242312343424133212222221221623132213242312314213213122222113
2342415122621132242242322221225542255222222222112241222232223222323213522222122246221231225232243224
6223131445352273462225532517237771421222422217426141752312626563272261233221417286234434252324661125
5222222212212422212223223322211422113212222441222322222222432222222222222222132132522224131242222451
3422323526233255413253234422122625354565276426242722342264341342322432242227231221345261423232251243
4455444352444254693544224343146552455424553454457554355354334375444452434455453544443455535455225454
6695865665676765678566666576961755966654564567555567567556642646397966556665359666465757356556757769
8357544347353366537753222233513443263326227543433534321424453266343553435425423918643343433235261323
2222222222222221222113122221132222411225322222222222222441122332222222232132115232313221145522221221
2224124212242232553331122222231252712234224682324732533127244253223113212252422561212242222267412142
2155131243437642435225242233334327262528545127324323242251223242215932221342512431224563331215223232
3233233821422242243223423226322333331221244225322333614732324322164332232342254245324342223324333333
5323233433722283363642223343334264332334256668558433344333335344774523223633116853423338533332265733
6636218835567665856535755855763526554865876567668671763558535573733875754666654864563576447378687647
3242212222532222453222221222221414445243225223253221212124423422213112225222222212136322222122223223
3246242324335263534434465364444433354444733144444444634444442415237463482176214523646425165642842254
2222122121452242222112223321223211222122412432421222323122222422224234323112221412442225322222244223
5555533353644375536354623527576345645257454546563754453235344566547743535526353443675773695567647537
3333334233422333245534448312255264263533563132333625233423334335232332233333924442432512333355242243
5335324246344212334344347222166443335324633214664133136352235644245321635434234446546333352834514533
3232232233742222122234123363441422152241262422235221425422492124252122242244323222152522222164124334
3462333528242224232212331221524224225335332337777262223233218633225162762134332832833282226832233352
2632332326122221121112263242232222122432223221342223342224123122112324132321112262322121522112113221
2643223122321323333222122131322331333331122234423732236222323333323223232221311311224272231332243223
1222223121241124122212232223223222122522221122332123122232231322212311251223333222513332338312123112
2152323434738233433164425517324546331332242235424332433322422413432633344543243344744343237342432312
4131322231422253332322233423433322322232222122431221333113333223333234213123233223231323332233334323
2463363425242612416264341654545345115236122326652335252424331225332623114245461624526144136446312789
5832235534333334323334233312133213343133323333875344483233343683364244333343536273324539333242273393
5336252424463368242344342182144524854253313325351235445322225455244424225253125634815634443442624924

57
03_b/main.c Normal file
View File

@@ -0,0 +1,57 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/07 12:53:07 by dgaillet #+# #+# */
/* Updated: 2025/12/08 12:55:55 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
#include "get_next_char.h"
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
char *get_highest_nbr(char *base, size_t remain, char *actual_best, char *result)
{
// printf("Result = %s", result);
if (remain == 0)
return (result);
if ((strlen(base)) <= remain)
return (actual_best);
if (base[0] > actual_best[0])
actual_best = base;
actual_best = get_highest_nbr(base + 1, remain, actual_best, result);
// printf("%s\n", actual_best);
if (actual_best == base)
return (get_highest_nbr(base + 1, remain - 1, base + 1, ft_strjoin_new(result, actual_best, 0)));
return (actual_best);
}
int main(void)
{
char *temp;
char *highest_temp;
int fd;
unsigned long long result = 0;
fd = open("input", O_RDONLY);
temp = get_next_char(fd, '\n');
while (temp)
{
printf ("Actual comb : %s", temp);
highest_temp = get_highest_nbr(temp, 12, temp, ft_strdup(""));
printf("highest Comb : %s\n\n", highest_temp);
result += atoll(highest_temp);
free(highest_temp);
free(temp);
temp = get_next_char(fd, '\n');
}
close(fd);
printf("Result : %llu\n", result);
}

136
04/input Normal file
View File

@@ -0,0 +1,136 @@
@@@@@.@..@@.@@..@..@@@@.@@@...@@...@@.@@@@.@..@@....@.....@@..@@@@@@.@@.@@.@@.@@.@..@@@@@.@@@@@@@.@@@@@.@@@@@@@@@@@.@..@@@@..@@.@....@.@
.@@@@..@@@@@@..@.@@.@@@.@@@..@@@@@@.@...@@@@@.@@@@.@.@@.....@@@@@@.@@@@@.@@@@..@@.@.@@.@.@@.@@@@.@@.@@@@@@@.@@@..@@@@....@@@..@....@@...
.@@.@@....@@@..@.@.@@@@@@@@@.@@.@.@.@@@@..@@.@.@@@.@@@....@.@.@.@.@@.@..@@@@@@.@@@@@.@@@@.@..@.@@@@@.@@@@@@@..@@@@.@@@.@@@.@@@.@.@@@.@..
.@@@....@@@.@@.@@...@@.@@@@@@@@@@....@@.@@@@@@@@..@@.@..@@@.@.@....@...@@@.@..@@.@@@@@@..@.@@@@@@@@@@.@.@@@....@@..@@@..@@@@.@@.@@.@@@@.
@@@@@@.@@@..@@@..@@.@.@@@....@@@@..@@@.@..@.@@@@@@@@.@@@@.@.@.@@@@..@@.@..@@@@@@@...@@@.@@@@@@@.@@@@@@@..@@.@@@@@@@.@@.@@@@@@@.@...@@@@@
@@@..@.@@@@@..@@@....@.@@@@.@.@@@@.@.....@.......@..@...@@@...@@@@.@.@@.@.@@.@.@.@@@.@.......@@..@.@@..@@@@@@@@@@@@.@@.@@@...@..@@@@@.@.
@@@.@@@@.@@.@@@.@.@@.@.@..@@@@@@@@..@@@@@.@..@@@@.@@@..@@..@@.@@@@@@..@@@@@@@@.@.@@@.@...@.@.@@@@@@...@@@@.@@@@@@@..@.@@.@.@@@@@@@@@.@@.
@@...@@@@...@@@@@@@@@.@@@.@@@@..@@@@.@@@@@@.@.@.@.@@@@@.@@@@@.@@@@@@@@.@@..@.@.....@.@@@@@@.@@@.@..@@.@@@.@@@..@.@@@@...@@@@.....@@@.@@.
@.@@@.@.@.....@@.@@.@@@@...@@@@...@@@.@@@@@@@@@@@@@@.@@@@@@..@..@@.@@@@@..@@.@@@.@@@..@.@@@@@@.@@..@.@@@.@@@@@@@@@@@.@@@@@....@@@.@@@@@@
@@@@@@@@@.@@@@@@@.@...@.@..@@@..@..@@..@@.@@.@@@.@.@@@@@@@@@@@.@.@.@@@@@@.@@@.@@.@@@@.@.@@@@@@@@@..@@@@@@.@...@.@.@@.@.@@@@@@.@@@@@.@.@.
@@@...@.@@@@....@..@@.@@@@.@.@@.@@@.@.@...@@@@@@@@..@@@@.@@@@@@@......@...@..@@@@@@@@@@.@@.@@@@..@@@@...@@.@..@@@.@..@@@.@..@@@@@@@@.@@@
@@.@..@@.@@@.@@..@..@@@.@@@@@.@@@@@@@@@@@@@.@@..@@..@.@.@@@@.@.@..@@..@.@@.@@@.@@@@@@@@@@@@@@@.@@..@@@@@@@@@@@@@@@@@@.@@.@.@@@@..@@.@@@.
@@@@.@.@@.@@@@@@@@@@.@@@.......@@@@.@..@@.@.@@@.@@@.@@.@.@@.@.@@@.@@@.@.@@@.@@@@@@@@@.@..@@.@@..@@@@@@@@.@.@@..@@@.@@@.@@.@@@@.@@@@.@.@.
.@@@.@@.@..@@@@.@..@@..@@.@@.@@@..@@@@@.@.@@@.@@@@@@@@.@@@..@@@..@..@@@@@.@@@.@@.@@.@..@@@@@.@@@@@.@@.@..@@@@.@.@@..@@.@@@@.@@.@@@@@@@@@
@@.@.@@.@.@....@@@@..@.@@@@@@@...@@@@@.@@...@@@.@@@..@....@@.@@@.@.@@..@.@@@..@@@.@.@@@...@.@@@@..@@.@@@.@..@@@@@..@@.@@@@@@@@.@@@@@@@..
.@.@@.@@@@.@.@@.@..@......@.@.@.@.@@@.@@@.@@@@.@@@@@.@@@@@@@@...@.@.@.@.@.@.@@.@@@@@@@@..@@@@.@@@@@..@.@@.@@.@@.@@@@@@@@.@.@.@@.@@@@..@@
@@@.@@@@@.@@@.@.@@.@@.@@@..@.@@.@@@@..@.@..@@@@.@@@@.@@@.@@.@@@.@@@@@@@.@@@@...@@@@..@...@@.@@@@@@@@@..@@@@@@@@@@@.@@@@@.@@@@@@..@@..@@@
@.@@@@@.@@@.@@.@@@.@@..@.@@@.@@@@@@...@..@@@@@@@@@.@@@@@@@@@@@@@@@@.@@@@@.@@@@@@@@@@@@.@.@@.@@...@.@@.@.@.@@@.@@@..@@@@@.@.@@@@@..@..@..
@@....@..@.@@.@@@@@@@.@@@.@@@@@.@@.@@.@....@@..@@.@.@@.@@.@@@@.@.@@.@@@@..@@@@@@.@@..@@@@@.@@@@@.@.@@@@...@@@@.@@@@@@@.@@@@@@@@@@..@@@.@
@@@@@....@...@@@.@@@@.@@.@.@@@@@...@@@@.@.@@..@@.@@@@@.@@.......@..@@@@@@..@@...@@@.....@.@@@@.@@@@..@@@..@@.@@@..@.@.@.@@@.@...@..@@@@@
...@@@@@@..@@@..@@@@.@.@@@@@@.@.@@@...@.@@@.@@@@@@@@@.@@...@@.@@..@@@@...@@@@.@@.@@..@.@@.@@@.@@@@@@@.@..@.@...@..@.@....@@@..@@@@@@@@@@
@.@@@@@...@..@@@.@@@.@.@.@@@.@@@....@.@@@.@@..@.@@@@@@.@@..@@@@@@..@@.@@.@.@@@..@.@..@@..@@@@@@@.@.@@@.@@@.@.@@..@@@@@@@@@@@@..@@..@@.@.
@..@..@..@@@@@..@@...@@.@@@@.@@.@@.@.@@@.@@..@@..@@@..@.@@@@..@@@@.@@@@.@@.@@@.@@@@@@@...@@.@@..@.@@@@@@.@@@@@@.@.@.@.@.@@@.@..@.@@.@.@@
@@....@@@@@..@@@@@.@@@@@@...@@@@..@@@..@@@@@@@..@.@@@@@@@@.@.@@@@@@@@@@..@.@...@.@.@@..@@.@.@@.@@@@.@@.@@@.@@@..@@...@@@.@@.@@@@.@.@@@.@
.@@@.@@.@.@.@@@.@@@@@@@.@.@@@.@@@@@@@@.@...@.@..@@.@@@@@....@@@...@.@..@@@@.@.@@.@..@@@@@@@@@.@.@@@.@@..@.@@.@.@@@@@.@@@.@@@@@.@@.@@.@@@
.@@@@@.@.@@@@@@.@..@.@.@.@@@@....@@.@..@@.@@...@@.@@.@@@..@@@.....@@@.@@...@.@@.@@@@..@@@@.@@....@@..@.@.@@.@@@@@@@@.@@@.@.@.@.@@@@@@..@
...@@@.@.@@.@.@@.@@@@@@@.@@..@..@@..@@.@@@@@.@@@@..@.@.@..@@.@..@.@@@@@@@.@.@@@@@.@..@@@@.@@.@...@..@@@@@@.@@@@@@@@@@@..@@@@@@@@.@.@@.@@
@@@...@@@@@...@@..@.@.@@.@@@@..@@@.@@@@.@@@.@@@@@@@@@.@.@..@@@.@@@@@@@@.@.@@@@@@.@@@...@.@.@@@@@..@@@.@.@@.@@@.@..@@@.@@@@@.@@.@....@.@@
@@.@@@@..@.@@@@@@@.@.@@@@@@@..@@.@@...@@@..@@@@@@@@@.@...@@@@.@@...@@@@@.@.@@@@..@.@@@@...@@.@@@@...@@@.@.@@@.@@.@.@@@.@@.@@...@@..@@@@@
.@@...@@@@@@.@.@@@.@...@@@@@@..@@@@@.@@.@@@@@@@@@@@@.@@@@@.@.@@..@@@@@.@@.@..@@.@.@@@.@@@..@..@@@.@.@@@@@.@.@@.@@.@.@@.@@@..@@@@@.@@@@@@
@@..@@@@@@.@@.@@@.@@@@@@.@@@@@...@..@@@.@@@.@.@..@.@@@.@@@.@@@@@@.@@@..@@.@..@..@.@@@@@.@...@@...@@@@.@@.@.@@..@@@.@.@@.@.@@@@.@@...@.@.
@.@.@@.@@@.@.@@@.@.@@@.@.@...@@@.@@...@@.....@...@@..@.@@.@.@@@@@@@.@@.@@@@@@@.@.@@@.@..@.@.@..@@@@.@@.@.@.@.@@@@@@..@.@@.@@@.@@@..@@..@
@.@.@@@@.@@@@..@..@@.@@@@@@......@@@..@@..@.@@@@@.@@@@.@.@.@.@..@..@.@...@@@@@@.@.@@@@.@@.@@@@@.@.@@.@@@@@...@.@@@@@.@@@@@.@...@@.@@.@@@
..@@.@@.@@@@..@....@@@@..@@.@.@.@@@@.@@.@@@...@@@.@@..@....@@...@@@@.@@@@@....@@@@.@@.@@@@.@@@...@.@@@.@@@@.@@@....@.@@.@@.@...@@..@@@@@
@..@@.@@.@.@@@@@@.@@@@@@.@..@@@@.@.@@.@.@@.@@...@@@@@@.@@@@@...@@@@@@...@.@@@@@...@@@..@..@@@@.@@.@@.@@@@..@@@@@@@@@@@@@@.@@.@.@@.@.@.@@
@@@@.@.@@@.@@.@@.@@@.@..@...@@.@@@.@@@@@...@.@@@.@@@..@.@.@.@.....@@@@@@.@.@@@.@@.@@....@.@..@@@.....@@.@@@..@@@..@@.@@@.@@@.@@.@@@...@@
...@..@@.@..@@@@@@@.@@@.@@@@.@.@@@@@@@@@@@@.@@..@.@@@@@.@@@@@@@@.@@.@...@@.@@@@@@@.@@@@.@..@...@.@@@@..@@..@@.@@@.@.@...@@...@..@.@@@.@@
@@@@@@.@@.@.@.@@@.....@@@@@@@..@.@@@....@@@.@.@@@@..@@.@@@@...@@@@@@..@@@@.@..@.@.@@@.@.@@@@@.@@@@@@@@@...@@.@@@@@@@..@@...@@@@@@@.@.@.@
@@@@.@@@.@@.@.@.@@@@@@@@@.@@@@@...@.@.@@@.@@..@@@@@@@@@@@.@..@@..@@@@.@@..@@@@@@@@@@.@@..@....@@@@@@@@@.@...@@@@@.@@@.@@@@@..@@@.@@@.@@@
@.@@.@@..@@....@@.@@.@@@@@.@@@@@@@@@@@@@@..@@.@@@....@..@@@@.@..@.@@@@@@@@@.@@@...@.@@.@@...@@..@@..@.@@@@.@@@@.@.@@.@.@@.@@@@@@@@@..@.@
.@@@@@.@....@@.@.@@.@@@@@.@@.@@@@.@.@@.@.@@@.@@..@.@@@..@@.@..@@..@.@@@@@.@.@@@@..@@@@@...@@@.@.@@@@@@@@@@.@@@@.@@.@@@@..@@@.@@.@@@@@@.@
..@..@@@@@..@@@.@@@@@.@@@...@@.@@@@..@@@@@@@..@@@@.@@.@.@@.@@...@@..@@@.@@.@.@@@@...@..@@.@@@..@@..@.@@@@@@..@@@.@@@.@@.@@.@@@@...@.@@@.
@@@@@@@@@@@@.@@@.@@...@@@.@.@@.@@.@@.@.@....@@@@@.@.@@@@@@@@.@.@.@@@.@@@..@@@.@.@@...@@..@@@.@@@.@@@@@@@..@@@@@@@.@.@@@.@.@@@@@...@.@@@.
.@@@.@@.@..@@..@@.@@@.@@.@.@@@.@@@@@.@@@@@@@@.@.@.@@.@@@@@..@...@@@.@.@@@@@@@.@.@..@..@...@....@.@..@@@@@.@@@.@..@@@@.@@@.@.@@@@...@.@@@
..@@@..@@@@..@@@@.@@.@@@.@.....@@@@@@@@@.@@@@@@.@@@@@..@...@@@@@@@@@.@@.@@@@@@@..@@@@@@.@@.@@@@@.@.@@@@@@@.@@@@@@@@@..@@..@.@@@..@@@.@@@
@@@@@.@@..@..@.@..@.@@@@@@.@@@@@@@@.@@@@@@@@..@@.@..@@@@@@@@.@@@@@@...@@.....@.@@@@@@....@..@@.@..@.@@.@@.@@@.@@@@@@@.@@...@@.@@@@@@@@@@
.@.@@...@@.@.@.@@.@@@@@@@@@.@.@@@...@@..@@.@@@@.@@@@@@@@@.@@@@@@@@@...@...@@@@@.@@@@@@@@@@@@@.@@@@@@.@@@@@@@.@.@@@@.@.@.@.@.@@@@@.@@@..@
@..@@@@@.@..@@@@@@@.@@@.@@.@...@@@.@@@.@@.@.@@@.@@@@@@@.@...@@@..@@@@@@@..@.@.@..@@.@@..@@@..@@.@.@@@@@@@@.@@@@.@.@..@@.@@@@..@@@@@@@@@@
@@..@@.@@@@@@@@@@@@@.@.@.@@@.@@@@@@@.@@@@@..@.@@.@..@@@.@.@.@.@@.@...@.@@@@..@@@@.@.@.@@.@..@.@@.@@@.@@@@@.@.@@@.@.@@@@@.@.@.@@.@@@...@@
@@@.@@@.@@@@@.@...@.@@@@@.@@..@..@@@..@.@.@@@@@@......@.@@.@@@@@@..@@@@@@@@@..@..@.@.@@.@@@@.@@@@.@..@@@..@@...@@@.@@@@@@.@.@......@.@@@
@@@..@..@...@@@@@@@@@@.@@@..@.@@..@@@.@@@@.@@..@@@@@..@.@..@@@@.@.@.@..@@@.@@.@.@@.@...@.@@@@@@.@..@@@@@@@@@@@@@@@.@@@@@.@@.@@@@@.@.@@..
..@@@.@@...@@@@@..@@.@@.@@@@@@@@.@@@@@@...@@....@@...@@@@@@@@@@@.@@.@@@...@@@.@@@@.@.@@@@.@@.@@@.@@@@@@@@@@..@@.@..@@.@@.@@@@.@.@@.@...@
.@@.@@..@@@@@.@@..@@@@@@.@....@.@@@@..@.@..@.@@@...@@@.@.@@@@@@@.@.@@.@@.@@.@@.@@...@@@@@@.@@@@.@.@@@@@@@@...@@.@@@.@@.@@@@@.@...@@@@@@@
.@@@@.@@@@@.@@@.@@.@.@.@@@.@.@.@@..@@@.@@...@@.@@.@@.@@@.@@@@@@.@.@@@.@..@..@@.@..@@@@@.@@.@.@@.@@.@..@@.@..@@@@.@@..@@@.@@@@@@@@.@.@..@
@@.@....@@@.@@.@@..@.@.@.@.@.@@..@@@@@.@@@..@@....@@.@@@..@@@@@..@.@.@@@@.@@@@.@@@@...@@@..@@@@@@.@..@@@.@@@@@@@@@@@..@@..@@@@.@@.@.@..@
..@.@@.@.@@@....@@@.@.@@@@@@@@@@.@@@...@.@@.@@.@@@@@@@.@.@@@@@@@@.@...@@@.@@@@@..@.@@.@..@.@@@@@..@@@@@@@@@@..@@.@@@@.@@@@@@@@@@...@..@.
@@..@@.@@@@@@@..@@..@@@@.@.@.@@.@.@@@@.@@@.@.@@..@....@@@.@@@....@@.@@@.@@...@@@..@@.@@...@@@.@@@....@@@.@@@.@@@@..@@..@.@@.@@..@@@.@@@@
@@.@.@@@@@@@@@@@@@..@@@..@@.@@@@@@@@@@@@.@..@.@@@@@.@.@@@..@@.@@@@@...@@..@@@..@...@@.@..@.@...@@....@.@@.@..@.@@@@@@.@@@.@.@@.@.@@.@@..
@.@.@@@@@@@@@@..@..@@.@.@@@@@@@@.@@..@@@@@.@@@@@.@..@..@@@.@@@.@@@@.@.....@@@@.@@@@@@@@@@.@@@@@.@@@..@@@.@@@..@.....@@...@..@.@@@..@@@@@
....@@@@.@..@@@.@@@@...@@@@.@.@.@.@@..@....@@..@@@.@....@@@.@@@..@@@@@....@..@@.@.@.@@.@@@.@..@@@@.@....@@@@@@.@@@@..@.@@.@.@@.@.@@@.@.@
@.@...@@@@@@@@@.@@@@@@.@.@.@@@..@@.@.@.@@@@@@.@@....@.@@..@.@.@@@@.@@@@@@.@@@.@@.@..@@.@.@@@...@@@.@.@@..@.@@.@.@.@@@@@@@@.@@@@@...@@@@.
@@.@.@@@@@.@@@.@@@.@@@.@@@..@@@.@.@.@@@@.@..@@@@.@@@@@@@@@.@@...@@@.@@.@..@....@@@@@@@.@.@@@@@@.@@..@.@@@.@@@@@@...@.@.@....@.@.@@.@@@@.
@@@.....@..@@@@.@.@@@@@@@...@.@@@.@@@.@@.@@@@@@...@@.@.@@@...@@@@@@@..@@@...@.@...@@@@@.@@..@...@@@@@.@@@.@.@@@.@@..@.@@..@@@@@@@.@.@..@
@@@@@@@.@.@@..@@@@@@@@@...@.@.@@@@.@..@.@.@.@@.@@.@@..@@@.@@@@@.@@@@@.@@@@.@.@@.@@.@.@@..@@@@..@..@@@@@@.@.@@@@@...@@.@..@..@.@@.@.@@..@
@.@@@@@@@@..@@...@@@.@@@@..@.@@@@@@...@.@@.@@@@@@.@@@@.@@..@.@.@@..@@..@@.@..@.@@..@..@@@@...@@@.@@.@@.@@.@@@@@..@@@.@..@.@@.@@@@@@...@.
@@.@.@@@@@@@@@@@@..@@@..@.@@@.@.@@@.@@@@...@@@@@@.@.@@@..@@@@@@@.@.@@@@@..@@@...@@@..@@..@...@@@@@..@@..@.@@.@.@@@@@@@@@@.@..@@@.@@@@.@.
..@@...@@@@@@@.@@.@.@@@@@@@..@@.@@@@..@@@@.@@..@@@.@@.@@.@@.@@.@.@@@..@...@.@@@@@.@@@@@@@@.@.@..@@@@@.@@.....@@@@..@@.@@@.....@@@@@..@@.
.@.@@@..@@@.@@@@@@..@@@@@@..@....@@@@@.@@@@@@.@@@...@@@@...@..@@.@@@@@@@@@@.@.@@@.@.@@..@.@@@@.@@.@.@..@.@@@@@@@..@@@@@@@@@..@.@....@.@@
@@@@@@@@@..@@...@@@@.@@@@.@....@.@@@@@@.@@@@@@@.@@.@.@@.@@@..@@@@@@.@@.@@.@@@@@@...@@@@@@@@@.@@@@..@@@..@..@..@@.@.@@@.@@@...@@...@..@@@
@@@..@.@@@.@@@..@.@...@@.@@@...@.@@..@.@@@@@@.@....@@.@@.@@@@@@@@.@@@@@@..@@.@.@.@@@@@..@..@@@.@.@..@@.@@...@.@@@@@.@..@@..@...@@.@@@..@
@..@@.@@@@@@.@.@@..@.@@@@@.@@@@@@@.@.@@@.@..@@@@@.@@@@@@@..@.@@@@@...@@@.@@.@.@@.@..@.@..@@@..@@@@@@@@@@@..@@.@.@@@@@.@@@..@@@......@@.@
.@@.@.@@@.@@.@.@@@@..@@@@@@..@..@@@@....@.@..@@.@@@@..@@@@.@@@@@@@@@...@.@@.@@@@.@@@@@@@@@..@.@@@@@@@@@@@@@@.@@@..@@.@@.....@@@@@@@@@...
@...@@@@.@@@@.@@@.@...@.@.@@.@@..@@..@..@@@@..@.@@.@@@.@@@@@@@@.@@@.@...@.@....@.@@.@@.@@.@..@@.@@.@@.@@.@@@@@.@@@@.@@@@@.@@.@@@@@..@.@@
@@@@@@@@..@@...@@..@@.@@@.@.@.@@@..@.@@@.@.@.@@@.@@@.@@...@@@@.@.@@@@@@@.@.@@@.@@.@@@.@@.@@@@@@.@.@@.@.@.@@@..@@@@.@@@@@@@....@@.@@...@@
@@@.@@@@@@@@@@@.@..@.@....@@@@@.@@@@@..@@@@.@@......@@@@@@@.@.@@@.@..@@@@.@.@@@@@.@@@.@..@.@@...@.@.@.@@.@...@..@@@..@@@.@..@@@@.@..@@@@
...@@.@@@.@@.@@@@@..@@..@@.@@...@.@@.@..@.@@@@.@@@...@..@@@@@@@@@@@@@.@@@@.@.@.@@.@@@.@.@@@@.@..@@@@.@.@@.@@.@@....@@..@@@@...@@@@@.@@.@
@@@@@......@@.@@@.@@...@@@@@@@.@.@@@....@@.@..@@.@@.@@@@@@@@@@@@..@....@@.@.@@.@@@@@@@@.@.@@@.@.@.@@@@@@@@@..@@@@.@...@.@@@@@@@..@.@..@.
@@@.@@.@.@@@@.@@@.@@@.@@@@..@..@@@@.@@@.@....@@@@@.@.@@@@@@.@.@@@@@@...@@..@@@.@@..@..@..@.@..@@@@.@@@@@@@@@@@.@@@.@@@@.@.@@@.@@...@..@.
...@.@@@.@.@@.@@@@@...@@.@@@@....@@@@@@@@@@@..@@.@..@@...@..@@.@@@@.@..@.@@@....@@@@.@@.@.@@@@@@@...@.@@..@.@@@.@@@@@..@@@@@.@@@@@@@@@@@
@@.@@@@@@@....@..@@@@@...@@.@@@@@....@.@.@@.@@@.@@.@@@@@.@@@@@@@@@@@.@.@@.@@@@@..@.@@@@@@@.@..@.@.@.@@@@..@@@@@@.@..@@@..@..@@@...@@.@..
@@@..@.@@@.@...@@@..@.........@@.@.@@@@.@..@@@@@@@@.@@@@.@@@@@@@.@@..@..@@@..@.@@@...@@@..@.@.@@@@.@.@@..@@@@.@..@@.@@@@..@@@.@@.@..@@..
@.@@@@@..@@@.@@.@.@@.@@@@@@@..@.@@.@.@@@..@.@@@.@@@@@@.@@@@@..@@.@@..@@@@@...@@@@.@@@.@@@..@@.@@@@@..@@@@@.@@@@.@...@.@.@.@..@@@.@@@@@..
.@@@....@@...@.@.@@.@.@@@@@@@@@@.@.@..@@.@@.@@....@..@@.@..@@@.@@@@@@.@@@.@@@@.@@..@..@.@..@@@@.@@@.@@@@@@@.@@@@.@@@@@@@@.@@@@.@@@@.@.@@
@@@@@@@@.@@@.@.@@@@@@@.@......@@.@@@.@..@@@.@.@..@@.@@.@.@.@.@@.@@@@.@@@@@.@.@@@.@@.@.@.@@@@.@@..@@@.@@..@@@@.@@@@@..@@@.@@@@.@@.@.@@@.@
@.@@@@..@@@@@...@@@@.@..@@@@@.@.@..@@.@@@....@..@@@....@.@@@..@..@@.@@@@..@@@@@@@...@...@@.@@@@@@..@@@@@@..@@@@@@@@.@@@.@@@@.@.@@.@.@@@@
@@.@@.@@.@@@@@.@.@@@.@..@@..@@@@@..@@@@@@@@@..@..@@@..@@@@@.@@..@@@@@@...@.@@@..@@..@@@.@@.@@@.@..@..@@@.@@..@@@@.@@@@@@.@.@..@@@..@.@.@
.@@@@@.@@@@@.@@@@@@@@@@@@.@@.@@....@@.@@.@@@@@@.@.@@@.@.@.@.@@@@@.@....@.@@.@@.@@.@@@@...@@@.@..@..@.@@@@@..@.@..@@@@@@@@@@@@@@.@@@@...@
..@..@@@.@..@@..@@@..@@@.@..@.@@@.@@@@@@.@.@.@@@@@..@@@@@.@..@.@@.@@@.@@@@@..@@@...@@@@.@@@@@@.@.@@@@.@@.@@....@....@@......@@@@@@..@@..
@@@@@@@.@.@@@@.@.@@.@@@@.@.@@@@.@.@@@.@@@@@@.@@@..@@.@..@@..@..@.@.@.@@@.@..@@...@.@@.@@@@.@...@.@@@@.@@..@@@@@@@.@@@@.@@@@@..@@@.@@@...
.@@@..@@@@.@@@.@@@@@.@@@...@..@..@@@@@..@.@@@..@@@@.@.@@@@.@@@.@.@@@.@@@@@@.@@@@..@@@.@.@.@@@....@@@@@@..@@@.@@..@.@@.@@..@.@@@@@@.@@@@.
@@.@..@.@@@@@.@@@@@@@@@.@.@@@@@@.@.@.@@...@..@..@.@@@@@@@@@@.@.@@.@...@..@.@.@@..@@@.@..@@@@..@@..@.@.@@@@@@.@.@.@@@@@@@..@.@@@@.@@@@@@@
.@..@..@@.@@...@.@@@@@@@.@@@@@@.@@.@@.@...@..@@@.@..@@@@..@...@@@.@..@.@@.@@@.@@.@.@@@@..@...@.@.@@.@@..@..@@.@@@.@...@@..@@@@@@..@@....
@@@..@@@@@@@.@@.@@@@..@..@@@...@@@@@@@@@.@.@..@@@..@@@@.@.@....@..@@@@@..@@@@@@@@@.@@@.@..@@@@@@..@@@...@.@@@@@.@@.@.@.@...@@@.@.@@..@@.
@@@.@.@@@@....@.@@@.@@@@@@@@@@@@@@@.@@.@.@@@@@@@@@.@.@@.@@.@@@.@@.@@.@@@@@@@@.@@.@..@..@@.@@.@@@....@@..@@@@@@@@@@....@@@@@..@@.@@.@@@@.
@..@@@@@@@@@@..@@..@.@.@.@@@@@@@@@@@@.@.@@.@@.@@..@.@@@@@.@@@@@@@@.@@@..@.@....@@..@@.@..@..@@@.@.@..@.@..@@@@@@@@@@..@.@.@@@..@@@@@@.@.
@@@@@.@@..@@@@@@@@@@@.@@@.....@.@@....@@@.@@@@.@.@@@@.@.@@.@@....@@.@@@@.@@.@..@..@@@@@..@@@..@@..@@@@.@@@.@..@@.@..@@...@@@@...@@@@.@@@
@@.@..@@..@...@@@.@.@....@@..@@@@.@@@@..@@@.@@@.@@@..@@@@..@@@@@@@@..@@@@@@@@.@..@....@.@.@@@@@@.@@@@@....@@@@@....@@@@.@@@....@@.@@.@@@
@@.@@@@.@@..@.@.@..@@.@...@@..@@@..@@@@..@@@@.@@.@..@...@.@@@@.@@@@@@.@...@@@....@@@@.@.@@..@@.@@@@@@@..@..@@.@@@@@@@@@@.@.@.@@@...@.@@@
.@..@@@@@..@@@@.@@@.@@..@@@@..@@@.@@.@..@.@..@@...@@.@@@@@@@.@@@@@@.@@.@@.@@@@@@@@@@..@...@@.@@@@..@@@@.@@.@@.@..@...@@@@...@.@@@@@..@@@
....@@@..@.@@@@@@.@@@@.@@@..@.@.@@.@@@@..@@@.@@@@.@.@@.@@..@..@@@......@.@@@@.@@.@.@.@@..@.@....@@@.@@.@@@@....@@@@@.@.@@@..@..@@.@@@..@
@@@@@.@.@@@@@..@@.@@@.@.@@@@.@...@@@.@.@@@@@@@@@@@@@..@@@@@..@@@@@.@.@.@@.@@@..@@@@...@..@@.@.@@@.@@@@@..@.@.@@@.@.@.@.@..@@@@..@.@@@@..
.@.@.@@@.@.@@.@@@.@@@@..@.@@@@..@.@@@.@@.@.@.@.@@@@..@@@.@@@@.@@@@@@@@@.@.@@@@@.@.@.@@@@@.@.@@.@.@@@.@@.@.@..@@@.@@@@@.@@@@@@@@..@@@@@@@
@..@@..@@..@..@@@.@@.@@.@@@.@.@@.@@@@..@@.@...@@.@@...@@@@..@.@.@...@.@.@.@@@@@@@@@.@@@@@@@@.@@.@@..@.@.....@...@@.@@.@@..@@@@...@@@@@@@
@@@.@@.@@@..@@@.@@@@@@.@@@.@@@.@@.@@@.@@.@.@..@@.@@...@@.@@.....@.@@@@.@@@.@.@@@@@.@@..@.@@@@@@.@.@@@@.@@.@..@@@@..@@@@.@@@@..@@@@@..@@@
.@..@@@@@@@@.@@.@@.@.@@.........@@.@@.@@@..@@..@@.@.@.@..@@@@.@@@@@@.@@@..@@@.@@@@.@@.@@.@@..@@@@@@@@.@@@@...@@@@@@...@@@@@.@....@@@@@@@
@@.@.@@@.@.@@...@.@@.@@@.@@@@@.@..@@.@@@.@...@@@@@@@@.@@@.@@@@@@.@@@.@.@.@@@.@.@@@@..@..@@..@..@@.....@..@@....@.@@@@@@.@@@@@@.@@.@@@@@.
@..@@@@@@.@.@@@@.@.@@.@@.....@.@.@@@.@@@.@@@....@.@@@.@@@.@@.@@@@.@@.@@.@@@......@@@.@@@@@@@@...@@@.@.@@@..@....@.@.@.@@.@@.....@@....@@
@.@@@.@@@@@.@@.@.@...@@.@@@@@.@@@@.@.@@.@@...@@.@@@@@@@@@@@@@@@@.@@.@@@@@@@.@@@@@@..@@@@@@@..@.@@.@..@.@.@@@@@.@@@@@@@@.@@@@.@@@@@@@..@.
@@.@.@@@@....@.@.@@@@@@.@@..@@@@@@@.@.@.@@@.@@@@@...@.@@....@@.@@.@@@@@.@.@.@@..@.@.@@@..@@.@@@..@@@@@@.@@@@@...@.@@@@@.@@@@.@@.@.@.@@@@
@.@.@.@@@@@...@.@@.@@.@@@@@...@.@@..@@.@.@@@.@.@..@@.@@.@..@..@@@@@@@@@.@@@....@@..@.@@.@.@.@@@.@..@@@@@@@@@@.@.@@..@@.@@@@@@@@@@@@.@@.@
.@...@@@.@@.@@@.@@@@@@@.@@@@@@.@.@@.@@.@@.@@@@.@....@..@...@@.@@@@@@@.@@@@@@@@@@@@.@@@@@@...@@@@@..@@@.@.@..@@@@@.@@@...@@@@@.@@@@@@@@@@
.@@..@.@.@@.@@.@@@@@@@@.....@.@@.@..@@@.@@.@@.@@@@.....@.@@@@@.@@@..@.@@....@.@.@@..@..@.@@@..@@.@.@@.@@.@@@@.@@@@@..@@@@@@@...@@.@.@..@
.@.@@..@@@@@....@@@@@@@.@..@.@@@@@..@.@.@@@@@@@@@.@.@@...@.@@.@.@@.@@.@@@@@.@..@..@.@.@@@@@@@...@..@@@@@@@@.@@@@@.@.@.@@@@@.@.@.@.@.@@@@
@.@@@.@@@.@@@@.@@@@@@.@@.@@.@.@@..@...@@..@.@.@@..@@@.@.@@.@@@.@@@...@@@@.@..@@@.@.@@..@@@@@@...@@.@@@@@.@@.@@...@.@.@@.@..@@......@@@.@
.@@..@@@@@@@@@...@@.@@@@@@@.@@@@..@@@.@.@@..@@.@.@.@....@@@@@@@@.@@@.@.....@@@@...@@.@@.@.@@.@..@@@.@@@@@@@@@...@.@.@.@@@@.@@@.@@@.@@@.@
@@@...@..@@@@.@@.@@@@@.@@@@@..@@@@@@@@@.@@@..@@..@@@@.@@.@.@...@.@.@@@@@@@@@@..@@@@@@.@@...@@.@..@@@@@.@@@@@@@@.@@...@@.@.@@.@@@..@@.@@@
@@@.@@@@@@.@@.@.@@.@@@.@..@.@.....@@@@@.@@....@@.@..@@@@@.@@@..@@@..@@.@@@.@@@.@@.@@@@@@.@.@@@..@@@@.@@@..@@@..@@@.@@@....@.@@@.@...@.@.
@.@@.@@@@.@@@..@.@@@.@@.@@...@...@@..@@@@@@.@@.@@@@@@@..@@@@@@@@@.@.@@.@@@@@@..@@..@.@..@.@@@@..@@@@@@@@.@@@.@@@@..@.@.@@.@@.@@@@@@.@@@@
@..@@...@.@.@@@.@.@.....@..@.@@..@.@..@@@@.@@@..@@.@@@..@@.@@..@.@...@..@@.@..@@@.@@.@@@.@@@.@@.@@@@.@@@.@@@@.@...@@@@@.@@@@@..@@@@.@..@
.@.@@@.@@.@@.@@.@@@.@@@@@@@@..@@@...@.@@.@@.@@.@@@@@@@@.@.....@.@.@@@@@@@.@.@.@@@@@.@@@@@@@@@@@@@.@@.@@..@.@...@.@@@..@@@.@@.@.@@.@.@..@
@@@..@@@.@@@@@@@@@@.@..@@.@@@.@@@@@@..@@..@@@.@.@....@@@@@@.@@@@@@@@.@@...@@@..@@...@@@..@.@@..@@@@@..@@@@.@@@.@.@@@@...@..@.@.@@.@@.@..
..@@.@.@.@@..@...@..@...@@@.@@@@@@@@@..@@@@@@..@@@@.@@@@.@@@@...@@@@@@@@@@.@@@@@@@@..@.@@@@@@@@....@@@@@@@@@@....@@....@@@@..@.@@@.@.@@@
@.@.@@@@.@@.@.@.@@..@.@@@@.@@.@@@@.@@@@@.@@@.@@@@@@@@@.@@@@.@@.@.@@@@.@@@@.@@@@..@@@@.@.@@.@.@.@@@@@@@.@@.@@@@@...@@@@.@@@@@@@..@@@@.@@@
.@@.@@@@@@.@.@.@@@@@@..@..@@@@....@@..@@@.@@@@@...@@@@@.@@..@@@@..@.@.@@@@.@.@...@...@@.@..@@@...@@@..@.@@@@@...@@..@@@@.@@@@@...@@.@.@@
@@@@@....@...@@..@.@...@...@@@@@@.@.@@@@.@@@@@@@.@..@@@@@@@@..@@@@...@@.@@.@.@@.@@...@@@@.@.@@@.@@..@@@@.@@@....@...@.@.@@.@.@..@..@.@@@
..@.@@.@@@@@@@@.@@.@@.@@@...@@..@@@@@@@.@..@@..@@@.@@.@@.@...@@.@@@@@.@@@@@..@@@.@.@@.@@@@.@@@.@@@..@.@@@@@@@..@@@....@@@@....@@@..@.@@@
@@@.@@@.@@...@..@.@....@@@.@@..@@.@@@.@@.@@@.@@..@..@..@.@@@.@.@@@@@@@.@@..@@.@@@.@.@@@@@.@.@@@@@@@@..@@..@.@@.@@.@.@..@@.@..@.@@@@@@@@.
@@@@@.@@@.@..@@@.@@@@@@@@@@@.@@.@@@@@.@@@@@.@@..@@@@.@..@.@@@@@@...@@@@@@.@@..@@.@@.@@.@@..@@@@.@@.@...@@@@@@...@.@@@@@.@@@@@@@@@@@@.@.@
@.@..@..@....@@@@.@.@@@@@.@@@.@@@@@.@@@@@@@@...@@.@@@.@.@..@..@..@@@@@..@@.@@..@.@@.@@.@.@.@..@@.@@.@...@.@@@@@@.@.@..@.@@.@..@@@..@@@@@
@.@@@.@@.@@@@.@...@@@.@@@.@@@@@@@@.@@@@@@@@@@.@@@....@@@@.@@@...@@@.@.@@@@.@.@@@..@..@..@@.@@@@@@.@...@@@.@@@@.@@@@@@@@@....@@@.@@.@.@@.
@@@@..@@@@@.@@@@@@.@@@@...@..@@@.@@@@@@@.@.@@@.@.@.@@@@.@...@.@.@.@@...@@@@@@@@..@@@.@@...@@.@@@.@@@.@@@@@@@@@.@@@@.@@@..@@@@.@@@.@@@.@.
.@@@@@.@@@..@@@@@.@@@@@.@..@....@@.@@.@@@.@@@@@@@.@@@....@@@@@@@@@@@.@@..@.....@.@.@@@@@@@@..@...@@@.@@@@@@@@.@@.@@.@@@@.@@@@@.@@@..@.@.
@@..@.@.@.@@@@@.@.@@@....@.@.@.@.@@@@.@@@.@..@@@@@@..@@.@@@...@@@@@...@..@@@@.@.@@..@.@@.@@@@.@@@.@@@.@...@@@.@@@.@.@@@@.@@@@@@....@.@..
@.@.@@@@.@@@.@.@@@@..@@@@@@.@..@@@..@@.@@@@..@@@@.@.@.@.@@@.@.@.@@@@@@.@.@.@...@...@@..@@@@@.@@..@@@@@@@@@.@@@@.@@@.@.@@@@@@.@@@@@...@@.
.@.@..@@@@@@@.@@@@@@.@..@..@@@@@@@@@@@@@@@.@.@....@@@@@@@.@.@@.@@..@@@@.@.@.@.@@.@@.@@@@.@.@@@.@.@@@@@@@..@..@@@@@@@@.@@@@@@@.@.@.@.@@@@
...@@@@@@..@.@@@@@@@..@@@..@@@@@@@.@@...@..@@@.@@@@@...@.@.@.@@@@@@@@@@@..@@@@.@@@@.@...@.@@.@..@@.@@.@..@@@.@@@@@@@@.@.@.@.@@@..@@.@.@.

99
04/main.c Normal file
View File

@@ -0,0 +1,99 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 13:31:43 by dgaillet #+# #+# */
/* Updated: 2025/12/15 16:05:55 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "get_next_char.h"
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
static char **parsing(void)
{
int fd = open("input", O_RDONLY);
char *temp = get_next_char(fd, '\n');
char *new;
char *str = NULL;
char **wall;
while (temp)
{
if (!str)
new = ft_strdup(temp);
else
{
new = ft_strjoin(str, temp);
free(str);
}
free(temp);
str = new;
temp = get_next_char(fd, '\n');
}
wall = ft_split(str, '\n');
return (free(str), wall);
}
static int is_roll(char **wall, int i, int j)
{
if (wall[i][j] == '@')
return (1);
return (0);
}
static int roll_arround(char **wall, int i, int j)
{
int rolls = 0;
int k = -1;
while (k <= 1)
{
if (i + k >= 0 && wall[i + k])
{
if (j > 0)
rolls += is_roll(wall, i + k, j - 1);
if (k)
rolls += is_roll(wall, i + k, j);
rolls += is_roll(wall, i + k, j + 1);
}
k++;
}
return (rolls);
}
int main(void)
{
char **wall = parsing();
int nb_fl = 0;
int temp;
int i = 0;
int j;
while (wall[i])
{
j = 0;
while (wall[i][j])
{
if (is_roll(wall, i, j))
{
temp = roll_arround(wall, i, j);
if (temp < 4)
nb_fl++;
}
j++;
}
i++;
}
i = -1;
while (wall[++i])
free(wall[i]);
free(wall);
printf("%d\n", nb_fl);
}

27
04_b/aoc04_b.h Normal file
View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aoc04_b.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/15 16:15:37 by dgaillet #+# #+# */
/* Updated: 2025/12/15 16:33:20 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef AOC04_B_H
# define AOC04_B_H
typedef struct s_co
{
int i;
int j;
void *next;
} t_co;
t_co *new_co(int i, int j);
void co_add_back(t_co **lst, t_co *new);
void clear_lst(t_co *lst);
#endif

10
04_b/example Normal file
View File

@@ -0,0 +1,10 @@
..@@.@@@@.
@@@.@.@.@@
@@@@@.@.@@
@.@@@@..@.
@@.@@@@.@@
.@@@@@@@.@
.@.@.@.@@@
@.@@@.@@@@
.@@@@@@@@.
@.@.@@@.@.

136
04_b/input Normal file
View File

@@ -0,0 +1,136 @@
@@@@@.@..@@.@@..@..@@@@.@@@...@@...@@.@@@@.@..@@....@.....@@..@@@@@@.@@.@@.@@.@@.@..@@@@@.@@@@@@@.@@@@@.@@@@@@@@@@@.@..@@@@..@@.@....@.@
.@@@@..@@@@@@..@.@@.@@@.@@@..@@@@@@.@...@@@@@.@@@@.@.@@.....@@@@@@.@@@@@.@@@@..@@.@.@@.@.@@.@@@@.@@.@@@@@@@.@@@..@@@@....@@@..@....@@...
.@@.@@....@@@..@.@.@@@@@@@@@.@@.@.@.@@@@..@@.@.@@@.@@@....@.@.@.@.@@.@..@@@@@@.@@@@@.@@@@.@..@.@@@@@.@@@@@@@..@@@@.@@@.@@@.@@@.@.@@@.@..
.@@@....@@@.@@.@@...@@.@@@@@@@@@@....@@.@@@@@@@@..@@.@..@@@.@.@....@...@@@.@..@@.@@@@@@..@.@@@@@@@@@@.@.@@@....@@..@@@..@@@@.@@.@@.@@@@.
@@@@@@.@@@..@@@..@@.@.@@@....@@@@..@@@.@..@.@@@@@@@@.@@@@.@.@.@@@@..@@.@..@@@@@@@...@@@.@@@@@@@.@@@@@@@..@@.@@@@@@@.@@.@@@@@@@.@...@@@@@
@@@..@.@@@@@..@@@....@.@@@@.@.@@@@.@.....@.......@..@...@@@...@@@@.@.@@.@.@@.@.@.@@@.@.......@@..@.@@..@@@@@@@@@@@@.@@.@@@...@..@@@@@.@.
@@@.@@@@.@@.@@@.@.@@.@.@..@@@@@@@@..@@@@@.@..@@@@.@@@..@@..@@.@@@@@@..@@@@@@@@.@.@@@.@...@.@.@@@@@@...@@@@.@@@@@@@..@.@@.@.@@@@@@@@@.@@.
@@...@@@@...@@@@@@@@@.@@@.@@@@..@@@@.@@@@@@.@.@.@.@@@@@.@@@@@.@@@@@@@@.@@..@.@.....@.@@@@@@.@@@.@..@@.@@@.@@@..@.@@@@...@@@@.....@@@.@@.
@.@@@.@.@.....@@.@@.@@@@...@@@@...@@@.@@@@@@@@@@@@@@.@@@@@@..@..@@.@@@@@..@@.@@@.@@@..@.@@@@@@.@@..@.@@@.@@@@@@@@@@@.@@@@@....@@@.@@@@@@
@@@@@@@@@.@@@@@@@.@...@.@..@@@..@..@@..@@.@@.@@@.@.@@@@@@@@@@@.@.@.@@@@@@.@@@.@@.@@@@.@.@@@@@@@@@..@@@@@@.@...@.@.@@.@.@@@@@@.@@@@@.@.@.
@@@...@.@@@@....@..@@.@@@@.@.@@.@@@.@.@...@@@@@@@@..@@@@.@@@@@@@......@...@..@@@@@@@@@@.@@.@@@@..@@@@...@@.@..@@@.@..@@@.@..@@@@@@@@.@@@
@@.@..@@.@@@.@@..@..@@@.@@@@@.@@@@@@@@@@@@@.@@..@@..@.@.@@@@.@.@..@@..@.@@.@@@.@@@@@@@@@@@@@@@.@@..@@@@@@@@@@@@@@@@@@.@@.@.@@@@..@@.@@@.
@@@@.@.@@.@@@@@@@@@@.@@@.......@@@@.@..@@.@.@@@.@@@.@@.@.@@.@.@@@.@@@.@.@@@.@@@@@@@@@.@..@@.@@..@@@@@@@@.@.@@..@@@.@@@.@@.@@@@.@@@@.@.@.
.@@@.@@.@..@@@@.@..@@..@@.@@.@@@..@@@@@.@.@@@.@@@@@@@@.@@@..@@@..@..@@@@@.@@@.@@.@@.@..@@@@@.@@@@@.@@.@..@@@@.@.@@..@@.@@@@.@@.@@@@@@@@@
@@.@.@@.@.@....@@@@..@.@@@@@@@...@@@@@.@@...@@@.@@@..@....@@.@@@.@.@@..@.@@@..@@@.@.@@@...@.@@@@..@@.@@@.@..@@@@@..@@.@@@@@@@@.@@@@@@@..
.@.@@.@@@@.@.@@.@..@......@.@.@.@.@@@.@@@.@@@@.@@@@@.@@@@@@@@...@.@.@.@.@.@.@@.@@@@@@@@..@@@@.@@@@@..@.@@.@@.@@.@@@@@@@@.@.@.@@.@@@@..@@
@@@.@@@@@.@@@.@.@@.@@.@@@..@.@@.@@@@..@.@..@@@@.@@@@.@@@.@@.@@@.@@@@@@@.@@@@...@@@@..@...@@.@@@@@@@@@..@@@@@@@@@@@.@@@@@.@@@@@@..@@..@@@
@.@@@@@.@@@.@@.@@@.@@..@.@@@.@@@@@@...@..@@@@@@@@@.@@@@@@@@@@@@@@@@.@@@@@.@@@@@@@@@@@@.@.@@.@@...@.@@.@.@.@@@.@@@..@@@@@.@.@@@@@..@..@..
@@....@..@.@@.@@@@@@@.@@@.@@@@@.@@.@@.@....@@..@@.@.@@.@@.@@@@.@.@@.@@@@..@@@@@@.@@..@@@@@.@@@@@.@.@@@@...@@@@.@@@@@@@.@@@@@@@@@@..@@@.@
@@@@@....@...@@@.@@@@.@@.@.@@@@@...@@@@.@.@@..@@.@@@@@.@@.......@..@@@@@@..@@...@@@.....@.@@@@.@@@@..@@@..@@.@@@..@.@.@.@@@.@...@..@@@@@
...@@@@@@..@@@..@@@@.@.@@@@@@.@.@@@...@.@@@.@@@@@@@@@.@@...@@.@@..@@@@...@@@@.@@.@@..@.@@.@@@.@@@@@@@.@..@.@...@..@.@....@@@..@@@@@@@@@@
@.@@@@@...@..@@@.@@@.@.@.@@@.@@@....@.@@@.@@..@.@@@@@@.@@..@@@@@@..@@.@@.@.@@@..@.@..@@..@@@@@@@.@.@@@.@@@.@.@@..@@@@@@@@@@@@..@@..@@.@.
@..@..@..@@@@@..@@...@@.@@@@.@@.@@.@.@@@.@@..@@..@@@..@.@@@@..@@@@.@@@@.@@.@@@.@@@@@@@...@@.@@..@.@@@@@@.@@@@@@.@.@.@.@.@@@.@..@.@@.@.@@
@@....@@@@@..@@@@@.@@@@@@...@@@@..@@@..@@@@@@@..@.@@@@@@@@.@.@@@@@@@@@@..@.@...@.@.@@..@@.@.@@.@@@@.@@.@@@.@@@..@@...@@@.@@.@@@@.@.@@@.@
.@@@.@@.@.@.@@@.@@@@@@@.@.@@@.@@@@@@@@.@...@.@..@@.@@@@@....@@@...@.@..@@@@.@.@@.@..@@@@@@@@@.@.@@@.@@..@.@@.@.@@@@@.@@@.@@@@@.@@.@@.@@@
.@@@@@.@.@@@@@@.@..@.@.@.@@@@....@@.@..@@.@@...@@.@@.@@@..@@@.....@@@.@@...@.@@.@@@@..@@@@.@@....@@..@.@.@@.@@@@@@@@.@@@.@.@.@.@@@@@@..@
...@@@.@.@@.@.@@.@@@@@@@.@@..@..@@..@@.@@@@@.@@@@..@.@.@..@@.@..@.@@@@@@@.@.@@@@@.@..@@@@.@@.@...@..@@@@@@.@@@@@@@@@@@..@@@@@@@@.@.@@.@@
@@@...@@@@@...@@..@.@.@@.@@@@..@@@.@@@@.@@@.@@@@@@@@@.@.@..@@@.@@@@@@@@.@.@@@@@@.@@@...@.@.@@@@@..@@@.@.@@.@@@.@..@@@.@@@@@.@@.@....@.@@
@@.@@@@..@.@@@@@@@.@.@@@@@@@..@@.@@...@@@..@@@@@@@@@.@...@@@@.@@...@@@@@.@.@@@@..@.@@@@...@@.@@@@...@@@.@.@@@.@@.@.@@@.@@.@@...@@..@@@@@
.@@...@@@@@@.@.@@@.@...@@@@@@..@@@@@.@@.@@@@@@@@@@@@.@@@@@.@.@@..@@@@@.@@.@..@@.@.@@@.@@@..@..@@@.@.@@@@@.@.@@.@@.@.@@.@@@..@@@@@.@@@@@@
@@..@@@@@@.@@.@@@.@@@@@@.@@@@@...@..@@@.@@@.@.@..@.@@@.@@@.@@@@@@.@@@..@@.@..@..@.@@@@@.@...@@...@@@@.@@.@.@@..@@@.@.@@.@.@@@@.@@...@.@.
@.@.@@.@@@.@.@@@.@.@@@.@.@...@@@.@@...@@.....@...@@..@.@@.@.@@@@@@@.@@.@@@@@@@.@.@@@.@..@.@.@..@@@@.@@.@.@.@.@@@@@@..@.@@.@@@.@@@..@@..@
@.@.@@@@.@@@@..@..@@.@@@@@@......@@@..@@..@.@@@@@.@@@@.@.@.@.@..@..@.@...@@@@@@.@.@@@@.@@.@@@@@.@.@@.@@@@@...@.@@@@@.@@@@@.@...@@.@@.@@@
..@@.@@.@@@@..@....@@@@..@@.@.@.@@@@.@@.@@@...@@@.@@..@....@@...@@@@.@@@@@....@@@@.@@.@@@@.@@@...@.@@@.@@@@.@@@....@.@@.@@.@...@@..@@@@@
@..@@.@@.@.@@@@@@.@@@@@@.@..@@@@.@.@@.@.@@.@@...@@@@@@.@@@@@...@@@@@@...@.@@@@@...@@@..@..@@@@.@@.@@.@@@@..@@@@@@@@@@@@@@.@@.@.@@.@.@.@@
@@@@.@.@@@.@@.@@.@@@.@..@...@@.@@@.@@@@@...@.@@@.@@@..@.@.@.@.....@@@@@@.@.@@@.@@.@@....@.@..@@@.....@@.@@@..@@@..@@.@@@.@@@.@@.@@@...@@
...@..@@.@..@@@@@@@.@@@.@@@@.@.@@@@@@@@@@@@.@@..@.@@@@@.@@@@@@@@.@@.@...@@.@@@@@@@.@@@@.@..@...@.@@@@..@@..@@.@@@.@.@...@@...@..@.@@@.@@
@@@@@@.@@.@.@.@@@.....@@@@@@@..@.@@@....@@@.@.@@@@..@@.@@@@...@@@@@@..@@@@.@..@.@.@@@.@.@@@@@.@@@@@@@@@...@@.@@@@@@@..@@...@@@@@@@.@.@.@
@@@@.@@@.@@.@.@.@@@@@@@@@.@@@@@...@.@.@@@.@@..@@@@@@@@@@@.@..@@..@@@@.@@..@@@@@@@@@@.@@..@....@@@@@@@@@.@...@@@@@.@@@.@@@@@..@@@.@@@.@@@
@.@@.@@..@@....@@.@@.@@@@@.@@@@@@@@@@@@@@..@@.@@@....@..@@@@.@..@.@@@@@@@@@.@@@...@.@@.@@...@@..@@..@.@@@@.@@@@.@.@@.@.@@.@@@@@@@@@..@.@
.@@@@@.@....@@.@.@@.@@@@@.@@.@@@@.@.@@.@.@@@.@@..@.@@@..@@.@..@@..@.@@@@@.@.@@@@..@@@@@...@@@.@.@@@@@@@@@@.@@@@.@@.@@@@..@@@.@@.@@@@@@.@
..@..@@@@@..@@@.@@@@@.@@@...@@.@@@@..@@@@@@@..@@@@.@@.@.@@.@@...@@..@@@.@@.@.@@@@...@..@@.@@@..@@..@.@@@@@@..@@@.@@@.@@.@@.@@@@...@.@@@.
@@@@@@@@@@@@.@@@.@@...@@@.@.@@.@@.@@.@.@....@@@@@.@.@@@@@@@@.@.@.@@@.@@@..@@@.@.@@...@@..@@@.@@@.@@@@@@@..@@@@@@@.@.@@@.@.@@@@@...@.@@@.
.@@@.@@.@..@@..@@.@@@.@@.@.@@@.@@@@@.@@@@@@@@.@.@.@@.@@@@@..@...@@@.@.@@@@@@@.@.@..@..@...@....@.@..@@@@@.@@@.@..@@@@.@@@.@.@@@@...@.@@@
..@@@..@@@@..@@@@.@@.@@@.@.....@@@@@@@@@.@@@@@@.@@@@@..@...@@@@@@@@@.@@.@@@@@@@..@@@@@@.@@.@@@@@.@.@@@@@@@.@@@@@@@@@..@@..@.@@@..@@@.@@@
@@@@@.@@..@..@.@..@.@@@@@@.@@@@@@@@.@@@@@@@@..@@.@..@@@@@@@@.@@@@@@...@@.....@.@@@@@@....@..@@.@..@.@@.@@.@@@.@@@@@@@.@@...@@.@@@@@@@@@@
.@.@@...@@.@.@.@@.@@@@@@@@@.@.@@@...@@..@@.@@@@.@@@@@@@@@.@@@@@@@@@...@...@@@@@.@@@@@@@@@@@@@.@@@@@@.@@@@@@@.@.@@@@.@.@.@.@.@@@@@.@@@..@
@..@@@@@.@..@@@@@@@.@@@.@@.@...@@@.@@@.@@.@.@@@.@@@@@@@.@...@@@..@@@@@@@..@.@.@..@@.@@..@@@..@@.@.@@@@@@@@.@@@@.@.@..@@.@@@@..@@@@@@@@@@
@@..@@.@@@@@@@@@@@@@.@.@.@@@.@@@@@@@.@@@@@..@.@@.@..@@@.@.@.@.@@.@...@.@@@@..@@@@.@.@.@@.@..@.@@.@@@.@@@@@.@.@@@.@.@@@@@.@.@.@@.@@@...@@
@@@.@@@.@@@@@.@...@.@@@@@.@@..@..@@@..@.@.@@@@@@......@.@@.@@@@@@..@@@@@@@@@..@..@.@.@@.@@@@.@@@@.@..@@@..@@...@@@.@@@@@@.@.@......@.@@@
@@@..@..@...@@@@@@@@@@.@@@..@.@@..@@@.@@@@.@@..@@@@@..@.@..@@@@.@.@.@..@@@.@@.@.@@.@...@.@@@@@@.@..@@@@@@@@@@@@@@@.@@@@@.@@.@@@@@.@.@@..
..@@@.@@...@@@@@..@@.@@.@@@@@@@@.@@@@@@...@@....@@...@@@@@@@@@@@.@@.@@@...@@@.@@@@.@.@@@@.@@.@@@.@@@@@@@@@@..@@.@..@@.@@.@@@@.@.@@.@...@
.@@.@@..@@@@@.@@..@@@@@@.@....@.@@@@..@.@..@.@@@...@@@.@.@@@@@@@.@.@@.@@.@@.@@.@@...@@@@@@.@@@@.@.@@@@@@@@...@@.@@@.@@.@@@@@.@...@@@@@@@
.@@@@.@@@@@.@@@.@@.@.@.@@@.@.@.@@..@@@.@@...@@.@@.@@.@@@.@@@@@@.@.@@@.@..@..@@.@..@@@@@.@@.@.@@.@@.@..@@.@..@@@@.@@..@@@.@@@@@@@@.@.@..@
@@.@....@@@.@@.@@..@.@.@.@.@.@@..@@@@@.@@@..@@....@@.@@@..@@@@@..@.@.@@@@.@@@@.@@@@...@@@..@@@@@@.@..@@@.@@@@@@@@@@@..@@..@@@@.@@.@.@..@
..@.@@.@.@@@....@@@.@.@@@@@@@@@@.@@@...@.@@.@@.@@@@@@@.@.@@@@@@@@.@...@@@.@@@@@..@.@@.@..@.@@@@@..@@@@@@@@@@..@@.@@@@.@@@@@@@@@@...@..@.
@@..@@.@@@@@@@..@@..@@@@.@.@.@@.@.@@@@.@@@.@.@@..@....@@@.@@@....@@.@@@.@@...@@@..@@.@@...@@@.@@@....@@@.@@@.@@@@..@@..@.@@.@@..@@@.@@@@
@@.@.@@@@@@@@@@@@@..@@@..@@.@@@@@@@@@@@@.@..@.@@@@@.@.@@@..@@.@@@@@...@@..@@@..@...@@.@..@.@...@@....@.@@.@..@.@@@@@@.@@@.@.@@.@.@@.@@..
@.@.@@@@@@@@@@..@..@@.@.@@@@@@@@.@@..@@@@@.@@@@@.@..@..@@@.@@@.@@@@.@.....@@@@.@@@@@@@@@@.@@@@@.@@@..@@@.@@@..@.....@@...@..@.@@@..@@@@@
....@@@@.@..@@@.@@@@...@@@@.@.@.@.@@..@....@@..@@@.@....@@@.@@@..@@@@@....@..@@.@.@.@@.@@@.@..@@@@.@....@@@@@@.@@@@..@.@@.@.@@.@.@@@.@.@
@.@...@@@@@@@@@.@@@@@@.@.@.@@@..@@.@.@.@@@@@@.@@....@.@@..@.@.@@@@.@@@@@@.@@@.@@.@..@@.@.@@@...@@@.@.@@..@.@@.@.@.@@@@@@@@.@@@@@...@@@@.
@@.@.@@@@@.@@@.@@@.@@@.@@@..@@@.@.@.@@@@.@..@@@@.@@@@@@@@@.@@...@@@.@@.@..@....@@@@@@@.@.@@@@@@.@@..@.@@@.@@@@@@...@.@.@....@.@.@@.@@@@.
@@@.....@..@@@@.@.@@@@@@@...@.@@@.@@@.@@.@@@@@@...@@.@.@@@...@@@@@@@..@@@...@.@...@@@@@.@@..@...@@@@@.@@@.@.@@@.@@..@.@@..@@@@@@@.@.@..@
@@@@@@@.@.@@..@@@@@@@@@...@.@.@@@@.@..@.@.@.@@.@@.@@..@@@.@@@@@.@@@@@.@@@@.@.@@.@@.@.@@..@@@@..@..@@@@@@.@.@@@@@...@@.@..@..@.@@.@.@@..@
@.@@@@@@@@..@@...@@@.@@@@..@.@@@@@@...@.@@.@@@@@@.@@@@.@@..@.@.@@..@@..@@.@..@.@@..@..@@@@...@@@.@@.@@.@@.@@@@@..@@@.@..@.@@.@@@@@@...@.
@@.@.@@@@@@@@@@@@..@@@..@.@@@.@.@@@.@@@@...@@@@@@.@.@@@..@@@@@@@.@.@@@@@..@@@...@@@..@@..@...@@@@@..@@..@.@@.@.@@@@@@@@@@.@..@@@.@@@@.@.
..@@...@@@@@@@.@@.@.@@@@@@@..@@.@@@@..@@@@.@@..@@@.@@.@@.@@.@@.@.@@@..@...@.@@@@@.@@@@@@@@.@.@..@@@@@.@@.....@@@@..@@.@@@.....@@@@@..@@.
.@.@@@..@@@.@@@@@@..@@@@@@..@....@@@@@.@@@@@@.@@@...@@@@...@..@@.@@@@@@@@@@.@.@@@.@.@@..@.@@@@.@@.@.@..@.@@@@@@@..@@@@@@@@@..@.@....@.@@
@@@@@@@@@..@@...@@@@.@@@@.@....@.@@@@@@.@@@@@@@.@@.@.@@.@@@..@@@@@@.@@.@@.@@@@@@...@@@@@@@@@.@@@@..@@@..@..@..@@.@.@@@.@@@...@@...@..@@@
@@@..@.@@@.@@@..@.@...@@.@@@...@.@@..@.@@@@@@.@....@@.@@.@@@@@@@@.@@@@@@..@@.@.@.@@@@@..@..@@@.@.@..@@.@@...@.@@@@@.@..@@..@...@@.@@@..@
@..@@.@@@@@@.@.@@..@.@@@@@.@@@@@@@.@.@@@.@..@@@@@.@@@@@@@..@.@@@@@...@@@.@@.@.@@.@..@.@..@@@..@@@@@@@@@@@..@@.@.@@@@@.@@@..@@@......@@.@
.@@.@.@@@.@@.@.@@@@..@@@@@@..@..@@@@....@.@..@@.@@@@..@@@@.@@@@@@@@@...@.@@.@@@@.@@@@@@@@@..@.@@@@@@@@@@@@@@.@@@..@@.@@.....@@@@@@@@@...
@...@@@@.@@@@.@@@.@...@.@.@@.@@..@@..@..@@@@..@.@@.@@@.@@@@@@@@.@@@.@...@.@....@.@@.@@.@@.@..@@.@@.@@.@@.@@@@@.@@@@.@@@@@.@@.@@@@@..@.@@
@@@@@@@@..@@...@@..@@.@@@.@.@.@@@..@.@@@.@.@.@@@.@@@.@@...@@@@.@.@@@@@@@.@.@@@.@@.@@@.@@.@@@@@@.@.@@.@.@.@@@..@@@@.@@@@@@@....@@.@@...@@
@@@.@@@@@@@@@@@.@..@.@....@@@@@.@@@@@..@@@@.@@......@@@@@@@.@.@@@.@..@@@@.@.@@@@@.@@@.@..@.@@...@.@.@.@@.@...@..@@@..@@@.@..@@@@.@..@@@@
...@@.@@@.@@.@@@@@..@@..@@.@@...@.@@.@..@.@@@@.@@@...@..@@@@@@@@@@@@@.@@@@.@.@.@@.@@@.@.@@@@.@..@@@@.@.@@.@@.@@....@@..@@@@...@@@@@.@@.@
@@@@@......@@.@@@.@@...@@@@@@@.@.@@@....@@.@..@@.@@.@@@@@@@@@@@@..@....@@.@.@@.@@@@@@@@.@.@@@.@.@.@@@@@@@@@..@@@@.@...@.@@@@@@@..@.@..@.
@@@.@@.@.@@@@.@@@.@@@.@@@@..@..@@@@.@@@.@....@@@@@.@.@@@@@@.@.@@@@@@...@@..@@@.@@..@..@..@.@..@@@@.@@@@@@@@@@@.@@@.@@@@.@.@@@.@@...@..@.
...@.@@@.@.@@.@@@@@...@@.@@@@....@@@@@@@@@@@..@@.@..@@...@..@@.@@@@.@..@.@@@....@@@@.@@.@.@@@@@@@...@.@@..@.@@@.@@@@@..@@@@@.@@@@@@@@@@@
@@.@@@@@@@....@..@@@@@...@@.@@@@@....@.@.@@.@@@.@@.@@@@@.@@@@@@@@@@@.@.@@.@@@@@..@.@@@@@@@.@..@.@.@.@@@@..@@@@@@.@..@@@..@..@@@...@@.@..
@@@..@.@@@.@...@@@..@.........@@.@.@@@@.@..@@@@@@@@.@@@@.@@@@@@@.@@..@..@@@..@.@@@...@@@..@.@.@@@@.@.@@..@@@@.@..@@.@@@@..@@@.@@.@..@@..
@.@@@@@..@@@.@@.@.@@.@@@@@@@..@.@@.@.@@@..@.@@@.@@@@@@.@@@@@..@@.@@..@@@@@...@@@@.@@@.@@@..@@.@@@@@..@@@@@.@@@@.@...@.@.@.@..@@@.@@@@@..
.@@@....@@...@.@.@@.@.@@@@@@@@@@.@.@..@@.@@.@@....@..@@.@..@@@.@@@@@@.@@@.@@@@.@@..@..@.@..@@@@.@@@.@@@@@@@.@@@@.@@@@@@@@.@@@@.@@@@.@.@@
@@@@@@@@.@@@.@.@@@@@@@.@......@@.@@@.@..@@@.@.@..@@.@@.@.@.@.@@.@@@@.@@@@@.@.@@@.@@.@.@.@@@@.@@..@@@.@@..@@@@.@@@@@..@@@.@@@@.@@.@.@@@.@
@.@@@@..@@@@@...@@@@.@..@@@@@.@.@..@@.@@@....@..@@@....@.@@@..@..@@.@@@@..@@@@@@@...@...@@.@@@@@@..@@@@@@..@@@@@@@@.@@@.@@@@.@.@@.@.@@@@
@@.@@.@@.@@@@@.@.@@@.@..@@..@@@@@..@@@@@@@@@..@..@@@..@@@@@.@@..@@@@@@...@.@@@..@@..@@@.@@.@@@.@..@..@@@.@@..@@@@.@@@@@@.@.@..@@@..@.@.@
.@@@@@.@@@@@.@@@@@@@@@@@@.@@.@@....@@.@@.@@@@@@.@.@@@.@.@.@.@@@@@.@....@.@@.@@.@@.@@@@...@@@.@..@..@.@@@@@..@.@..@@@@@@@@@@@@@@.@@@@...@
..@..@@@.@..@@..@@@..@@@.@..@.@@@.@@@@@@.@.@.@@@@@..@@@@@.@..@.@@.@@@.@@@@@..@@@...@@@@.@@@@@@.@.@@@@.@@.@@....@....@@......@@@@@@..@@..
@@@@@@@.@.@@@@.@.@@.@@@@.@.@@@@.@.@@@.@@@@@@.@@@..@@.@..@@..@..@.@.@.@@@.@..@@...@.@@.@@@@.@...@.@@@@.@@..@@@@@@@.@@@@.@@@@@..@@@.@@@...
.@@@..@@@@.@@@.@@@@@.@@@...@..@..@@@@@..@.@@@..@@@@.@.@@@@.@@@.@.@@@.@@@@@@.@@@@..@@@.@.@.@@@....@@@@@@..@@@.@@..@.@@.@@..@.@@@@@@.@@@@.
@@.@..@.@@@@@.@@@@@@@@@.@.@@@@@@.@.@.@@...@..@..@.@@@@@@@@@@.@.@@.@...@..@.@.@@..@@@.@..@@@@..@@..@.@.@@@@@@.@.@.@@@@@@@..@.@@@@.@@@@@@@
.@..@..@@.@@...@.@@@@@@@.@@@@@@.@@.@@.@...@..@@@.@..@@@@..@...@@@.@..@.@@.@@@.@@.@.@@@@..@...@.@.@@.@@..@..@@.@@@.@...@@..@@@@@@..@@....
@@@..@@@@@@@.@@.@@@@..@..@@@...@@@@@@@@@.@.@..@@@..@@@@.@.@....@..@@@@@..@@@@@@@@@.@@@.@..@@@@@@..@@@...@.@@@@@.@@.@.@.@...@@@.@.@@..@@.
@@@.@.@@@@....@.@@@.@@@@@@@@@@@@@@@.@@.@.@@@@@@@@@.@.@@.@@.@@@.@@.@@.@@@@@@@@.@@.@..@..@@.@@.@@@....@@..@@@@@@@@@@....@@@@@..@@.@@.@@@@.
@..@@@@@@@@@@..@@..@.@.@.@@@@@@@@@@@@.@.@@.@@.@@..@.@@@@@.@@@@@@@@.@@@..@.@....@@..@@.@..@..@@@.@.@..@.@..@@@@@@@@@@..@.@.@@@..@@@@@@.@.
@@@@@.@@..@@@@@@@@@@@.@@@.....@.@@....@@@.@@@@.@.@@@@.@.@@.@@....@@.@@@@.@@.@..@..@@@@@..@@@..@@..@@@@.@@@.@..@@.@..@@...@@@@...@@@@.@@@
@@.@..@@..@...@@@.@.@....@@..@@@@.@@@@..@@@.@@@.@@@..@@@@..@@@@@@@@..@@@@@@@@.@..@....@.@.@@@@@@.@@@@@....@@@@@....@@@@.@@@....@@.@@.@@@
@@.@@@@.@@..@.@.@..@@.@...@@..@@@..@@@@..@@@@.@@.@..@...@.@@@@.@@@@@@.@...@@@....@@@@.@.@@..@@.@@@@@@@..@..@@.@@@@@@@@@@.@.@.@@@...@.@@@
.@..@@@@@..@@@@.@@@.@@..@@@@..@@@.@@.@..@.@..@@...@@.@@@@@@@.@@@@@@.@@.@@.@@@@@@@@@@..@...@@.@@@@..@@@@.@@.@@.@..@...@@@@...@.@@@@@..@@@
....@@@..@.@@@@@@.@@@@.@@@..@.@.@@.@@@@..@@@.@@@@.@.@@.@@..@..@@@......@.@@@@.@@.@.@.@@..@.@....@@@.@@.@@@@....@@@@@.@.@@@..@..@@.@@@..@
@@@@@.@.@@@@@..@@.@@@.@.@@@@.@...@@@.@.@@@@@@@@@@@@@..@@@@@..@@@@@.@.@.@@.@@@..@@@@...@..@@.@.@@@.@@@@@..@.@.@@@.@.@.@.@..@@@@..@.@@@@..
.@.@.@@@.@.@@.@@@.@@@@..@.@@@@..@.@@@.@@.@.@.@.@@@@..@@@.@@@@.@@@@@@@@@.@.@@@@@.@.@.@@@@@.@.@@.@.@@@.@@.@.@..@@@.@@@@@.@@@@@@@@..@@@@@@@
@..@@..@@..@..@@@.@@.@@.@@@.@.@@.@@@@..@@.@...@@.@@...@@@@..@.@.@...@.@.@.@@@@@@@@@.@@@@@@@@.@@.@@..@.@.....@...@@.@@.@@..@@@@...@@@@@@@
@@@.@@.@@@..@@@.@@@@@@.@@@.@@@.@@.@@@.@@.@.@..@@.@@...@@.@@.....@.@@@@.@@@.@.@@@@@.@@..@.@@@@@@.@.@@@@.@@.@..@@@@..@@@@.@@@@..@@@@@..@@@
.@..@@@@@@@@.@@.@@.@.@@.........@@.@@.@@@..@@..@@.@.@.@..@@@@.@@@@@@.@@@..@@@.@@@@.@@.@@.@@..@@@@@@@@.@@@@...@@@@@@...@@@@@.@....@@@@@@@
@@.@.@@@.@.@@...@.@@.@@@.@@@@@.@..@@.@@@.@...@@@@@@@@.@@@.@@@@@@.@@@.@.@.@@@.@.@@@@..@..@@..@..@@.....@..@@....@.@@@@@@.@@@@@@.@@.@@@@@.
@..@@@@@@.@.@@@@.@.@@.@@.....@.@.@@@.@@@.@@@....@.@@@.@@@.@@.@@@@.@@.@@.@@@......@@@.@@@@@@@@...@@@.@.@@@..@....@.@.@.@@.@@.....@@....@@
@.@@@.@@@@@.@@.@.@...@@.@@@@@.@@@@.@.@@.@@...@@.@@@@@@@@@@@@@@@@.@@.@@@@@@@.@@@@@@..@@@@@@@..@.@@.@..@.@.@@@@@.@@@@@@@@.@@@@.@@@@@@@..@.
@@.@.@@@@....@.@.@@@@@@.@@..@@@@@@@.@.@.@@@.@@@@@...@.@@....@@.@@.@@@@@.@.@.@@..@.@.@@@..@@.@@@..@@@@@@.@@@@@...@.@@@@@.@@@@.@@.@.@.@@@@
@.@.@.@@@@@...@.@@.@@.@@@@@...@.@@..@@.@.@@@.@.@..@@.@@.@..@..@@@@@@@@@.@@@....@@..@.@@.@.@.@@@.@..@@@@@@@@@@.@.@@..@@.@@@@@@@@@@@@.@@.@
.@...@@@.@@.@@@.@@@@@@@.@@@@@@.@.@@.@@.@@.@@@@.@....@..@...@@.@@@@@@@.@@@@@@@@@@@@.@@@@@@...@@@@@..@@@.@.@..@@@@@.@@@...@@@@@.@@@@@@@@@@
.@@..@.@.@@.@@.@@@@@@@@.....@.@@.@..@@@.@@.@@.@@@@.....@.@@@@@.@@@..@.@@....@.@.@@..@..@.@@@..@@.@.@@.@@.@@@@.@@@@@..@@@@@@@...@@.@.@..@
.@.@@..@@@@@....@@@@@@@.@..@.@@@@@..@.@.@@@@@@@@@.@.@@...@.@@.@.@@.@@.@@@@@.@..@..@.@.@@@@@@@...@..@@@@@@@@.@@@@@.@.@.@@@@@.@.@.@.@.@@@@
@.@@@.@@@.@@@@.@@@@@@.@@.@@.@.@@..@...@@..@.@.@@..@@@.@.@@.@@@.@@@...@@@@.@..@@@.@.@@..@@@@@@...@@.@@@@@.@@.@@...@.@.@@.@..@@......@@@.@
.@@..@@@@@@@@@...@@.@@@@@@@.@@@@..@@@.@.@@..@@.@.@.@....@@@@@@@@.@@@.@.....@@@@...@@.@@.@.@@.@..@@@.@@@@@@@@@...@.@.@.@@@@.@@@.@@@.@@@.@
@@@...@..@@@@.@@.@@@@@.@@@@@..@@@@@@@@@.@@@..@@..@@@@.@@.@.@...@.@.@@@@@@@@@@..@@@@@@.@@...@@.@..@@@@@.@@@@@@@@.@@...@@.@.@@.@@@..@@.@@@
@@@.@@@@@@.@@.@.@@.@@@.@..@.@.....@@@@@.@@....@@.@..@@@@@.@@@..@@@..@@.@@@.@@@.@@.@@@@@@.@.@@@..@@@@.@@@..@@@..@@@.@@@....@.@@@.@...@.@.
@.@@.@@@@.@@@..@.@@@.@@.@@...@...@@..@@@@@@.@@.@@@@@@@..@@@@@@@@@.@.@@.@@@@@@..@@..@.@..@.@@@@..@@@@@@@@.@@@.@@@@..@.@.@@.@@.@@@@@@.@@@@
@..@@...@.@.@@@.@.@.....@..@.@@..@.@..@@@@.@@@..@@.@@@..@@.@@..@.@...@..@@.@..@@@.@@.@@@.@@@.@@.@@@@.@@@.@@@@.@...@@@@@.@@@@@..@@@@.@..@
.@.@@@.@@.@@.@@.@@@.@@@@@@@@..@@@...@.@@.@@.@@.@@@@@@@@.@.....@.@.@@@@@@@.@.@.@@@@@.@@@@@@@@@@@@@.@@.@@..@.@...@.@@@..@@@.@@.@.@@.@.@..@
@@@..@@@.@@@@@@@@@@.@..@@.@@@.@@@@@@..@@..@@@.@.@....@@@@@@.@@@@@@@@.@@...@@@..@@...@@@..@.@@..@@@@@..@@@@.@@@.@.@@@@...@..@.@.@@.@@.@..
..@@.@.@.@@..@...@..@...@@@.@@@@@@@@@..@@@@@@..@@@@.@@@@.@@@@...@@@@@@@@@@.@@@@@@@@..@.@@@@@@@@....@@@@@@@@@@....@@....@@@@..@.@@@.@.@@@
@.@.@@@@.@@.@.@.@@..@.@@@@.@@.@@@@.@@@@@.@@@.@@@@@@@@@.@@@@.@@.@.@@@@.@@@@.@@@@..@@@@.@.@@.@.@.@@@@@@@.@@.@@@@@...@@@@.@@@@@@@..@@@@.@@@
.@@.@@@@@@.@.@.@@@@@@..@..@@@@....@@..@@@.@@@@@...@@@@@.@@..@@@@..@.@.@@@@.@.@...@...@@.@..@@@...@@@..@.@@@@@...@@..@@@@.@@@@@...@@.@.@@
@@@@@....@...@@..@.@...@...@@@@@@.@.@@@@.@@@@@@@.@..@@@@@@@@..@@@@...@@.@@.@.@@.@@...@@@@.@.@@@.@@..@@@@.@@@....@...@.@.@@.@.@..@..@.@@@
..@.@@.@@@@@@@@.@@.@@.@@@...@@..@@@@@@@.@..@@..@@@.@@.@@.@...@@.@@@@@.@@@@@..@@@.@.@@.@@@@.@@@.@@@..@.@@@@@@@..@@@....@@@@....@@@..@.@@@
@@@.@@@.@@...@..@.@....@@@.@@..@@.@@@.@@.@@@.@@..@..@..@.@@@.@.@@@@@@@.@@..@@.@@@.@.@@@@@.@.@@@@@@@@..@@..@.@@.@@.@.@..@@.@..@.@@@@@@@@.
@@@@@.@@@.@..@@@.@@@@@@@@@@@.@@.@@@@@.@@@@@.@@..@@@@.@..@.@@@@@@...@@@@@@.@@..@@.@@.@@.@@..@@@@.@@.@...@@@@@@...@.@@@@@.@@@@@@@@@@@@.@.@
@.@..@..@....@@@@.@.@@@@@.@@@.@@@@@.@@@@@@@@...@@.@@@.@.@..@..@..@@@@@..@@.@@..@.@@.@@.@.@.@..@@.@@.@...@.@@@@@@.@.@..@.@@.@..@@@..@@@@@
@.@@@.@@.@@@@.@...@@@.@@@.@@@@@@@@.@@@@@@@@@@.@@@....@@@@.@@@...@@@.@.@@@@.@.@@@..@..@..@@.@@@@@@.@...@@@.@@@@.@@@@@@@@@....@@@.@@.@.@@.
@@@@..@@@@@.@@@@@@.@@@@...@..@@@.@@@@@@@.@.@@@.@.@.@@@@.@...@.@.@.@@...@@@@@@@@..@@@.@@...@@.@@@.@@@.@@@@@@@@@.@@@@.@@@..@@@@.@@@.@@@.@.
.@@@@@.@@@..@@@@@.@@@@@.@..@....@@.@@.@@@.@@@@@@@.@@@....@@@@@@@@@@@.@@..@.....@.@.@@@@@@@@..@...@@@.@@@@@@@@.@@.@@.@@@@.@@@@@.@@@..@.@.
@@..@.@.@.@@@@@.@.@@@....@.@.@.@.@@@@.@@@.@..@@@@@@..@@.@@@...@@@@@...@..@@@@.@.@@..@.@@.@@@@.@@@.@@@.@...@@@.@@@.@.@@@@.@@@@@@....@.@..
@.@.@@@@.@@@.@.@@@@..@@@@@@.@..@@@..@@.@@@@..@@@@.@.@.@.@@@.@.@.@@@@@@.@.@.@...@...@@..@@@@@.@@..@@@@@@@@@.@@@@.@@@.@.@@@@@@.@@@@@...@@.
.@.@..@@@@@@@.@@@@@@.@..@..@@@@@@@@@@@@@@@.@.@....@@@@@@@.@.@@.@@..@@@@.@.@.@.@@.@@.@@@@.@.@@@.@.@@@@@@@..@..@@@@@@@@.@@@@@@@.@.@.@.@@@@
...@@@@@@..@.@@@@@@@..@@@..@@@@@@@.@@...@..@@@.@@@@@...@.@.@.@@@@@@@@@@@..@@@@.@@@@.@...@.@@.@..@@.@@.@..@@@.@@@@@@@@.@.@.@.@@@..@@.@.@.

56
04_b/lst.c Normal file
View File

@@ -0,0 +1,56 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lst.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/15 16:17:12 by dgaillet #+# #+# */
/* Updated: 2025/12/15 16:26:55 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc04_b.h"
#include <stdlib.h>
t_co *new_co(int i, int j)
{
t_co *co;
co = malloc(sizeof(t_co));
if (!co)
return (NULL);
co->i = i;
co->j = j;
co->next = NULL;
return (co);
}
void co_add_back(t_co **lst, t_co *new)
{
t_co *temp;
if (!lst)
return ;
if (!(*lst))
*lst = new;
else
{
temp = *lst;
while (temp->next)
temp = temp->next;
temp->next = new;
}
}
void clear_lst(t_co *lst)
{
t_co *temp = lst;
while (temp)
{
temp = lst->next;
free(lst);
lst = temp;
}
}

131
04_b/main.c Normal file
View File

@@ -0,0 +1,131 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 13:31:43 by dgaillet #+# #+# */
/* Updated: 2025/12/16 10:24:41 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "aoc04_b.h"
#include "get_next_char.h"
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
// 1428 ; to low
static char **parsing(void)
{
int fd = open("input", O_RDONLY);
char *temp = get_next_char(fd, '\n');
char *new;
char *str = NULL;
char **wall;
while (temp)
{
if (!str)
new = ft_strdup(temp);
else
{
new = ft_strjoin(str, temp);
free(str);
}
free(temp);
str = new;
temp = get_next_char(fd, '\n');
}
wall = ft_split(str, '\n');
return (free(str), wall);
}
static int is_roll(char **wall, int i, int j)
{
if (wall[i][j] == '@')
return (1);
return (0);
}
static int roll_arround(char **wall, int i, int j)
{
int rolls = 0;
int k = -1;
while (k <= 1)
{
if (i + k >= 0 && wall[i + k])
{
if (j > 0)
rolls += is_roll(wall, i + k, j - 1);
if (k)
rolls += is_roll(wall, i + k, j);
rolls += is_roll(wall, i + k, j + 1);
}
k++;
}
return (rolls);
}
static void delete_rolls(char **wall, t_co *lst)
{
while (lst)
{
wall[lst->i][lst->j] = '.';
lst = lst->next;
}
}
static int nb_forklift(char **wall)
{
int nb_fl = 0;
int temp;
int i = 0;
int j;
t_co *lst = NULL;
while (wall[i])
{
j = 0;
while (wall[i][j])
{
if (is_roll(wall, i, j))
{
temp = roll_arround(wall, i, j);
if (temp < 4)
{
nb_fl++;
co_add_back(&lst, new_co(i, j));
}
}
j++;
}
i++;
}
delete_rolls(wall, lst);
clear_lst(lst);
return (nb_fl);
}
int main(void)
{
char **wall = parsing();
int nb_fl = 0;
int temp = 0;
int i = 0;
temp = nb_forklift(wall);
while (temp)
{
nb_fl += temp;
temp = nb_forklift(wall);
}
while (wall[++i])
free(wall[i]);
free(wall);
printf("%d\n", nb_fl);
}

26
05/aoc05.h Normal file
View File

@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aoc05.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 10:28:12 by dgaillet #+# #+# */
/* Updated: 2025/12/16 10:55:28 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef AOC05_H
# define AOC05_H
typedef struct s_range
{
long long start;
long long end;
void *next;
} t_range;
t_range *parsing(int fd);
void lst_clear(t_range *lst);
#endif

1183
05/input Normal file

File diff suppressed because it is too large Load Diff

48
05/main.c Normal file
View File

@@ -0,0 +1,48 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 10:44:11 by dgaillet #+# #+# */
/* Updated: 2025/12/16 10:55:36 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc05.h"
#include "get_next_char.h"
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
static int is_fresh(t_range *lst, long long ingredient)
{
while (lst)
{
if (lst->start <= ingredient && lst->end >= ingredient)
return (1);
lst = lst->next;
}
return (0);
}
int main(void)
{
int fd = open("input", O_RDONLY);
t_range *lst = parsing(fd);
int nb_fresh = 0;
char *temp;
temp = get_next_char(fd, '\n');
while (temp)
{
nb_fresh += is_fresh(lst, atoll(temp));
free(temp);
temp = get_next_char(fd, '\n');
}
close(fd);
lst_clear(lst);
printf("%d\n", nb_fresh);
}

77
05/parsing.c Normal file
View File

@@ -0,0 +1,77 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 10:30:27 by dgaillet #+# #+# */
/* Updated: 2025/12/16 10:55:01 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc05.h"
#include "get_next_char.h"
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
static t_range *new_range(char *str)
{
t_range *range;
range = malloc(sizeof(t_range));
if (!range)
return (NULL);
range->start = atoll(str);
range->end = atoll(strchr(str, '-') + 1);
range->next = NULL;
return (range);
}
static void range_add_back(t_range **lst, t_range *new)
{
t_range *temp;
if (!lst)
return ;
if (!(*lst))
*lst = new;
else
{
temp = *lst;
while (temp->next)
temp = temp->next;
temp->next = new;
}
}
void lst_clear(t_range *lst)
{
t_range *temp;
while (lst)
{
temp = lst->next;
free(lst);
lst = temp;
}
}
t_range *parsing(int fd)
{
t_range *lst = NULL;
char *temp;
temp = get_next_char(fd, '\n');
while (temp && strlen(temp) > 1)
{
range_add_back(&lst, new_range(temp));
free(temp);
temp = get_next_char(fd, '\n');
}
if (temp)
free(temp);
return (lst);
}

27
05_b/aoc05.h Normal file
View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aoc05.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 10:28:12 by dgaillet #+# #+# */
/* Updated: 2025/12/16 11:39:24 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef AOC05_H
# define AOC05_H
typedef struct s_range
{
long long start;
long long end;
void *next;
void *pre;
} t_range;
t_range *parsing(int fd);
void lst_clear(t_range *lst);
#endif

6
05_b/example Normal file
View File

@@ -0,0 +1,6 @@
3-5
10-14
16-20
12-18
10-20
1-1000

1183
05_b/input Normal file

File diff suppressed because it is too large Load Diff

72
05_b/main.c Normal file
View File

@@ -0,0 +1,72 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 10:44:11 by dgaillet #+# #+# */
/* Updated: 2025/12/16 15:25:14 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc05.h"
#include "get_next_char.h"
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
static void update_range(t_range *lst)
{
t_range *node = lst;
while (lst->pre)
lst = lst->pre;
while (lst != node)
{
if (node->start >= lst->start && node->start <= lst->end)
node->start = lst->end + 1;
if (node->end >= lst->start && node->end <= lst->end)
node->end = lst->start - 1;
if ((lst->start >= node->start && lst->start <= node->end)
&& (lst->end >= node->start && lst->end <= node->end))
{
lst->start = 0;
lst->end = -1;
}
lst = lst->next;
}
if (node->start > node->end)
{
node->start = 0;
node->end = -1;
}
}
int main(void)
{
int fd = open("input", O_RDONLY);
t_range *lst = parsing(fd);
unsigned long long nb_fresh = 0;
while (lst->next)
{
update_range(lst);
lst = lst->next;
}
update_range(lst);
while (lst->pre)
lst = lst->pre;
while (lst->next)
{
nb_fresh += 1 + lst->end - lst->start;
lst = lst->next;
}
nb_fresh += 1 + lst->end - lst->start;
while (lst->pre)
lst = lst->pre;
close(fd);
lst_clear(lst);
printf("\n%lld\n", nb_fresh);
}

79
05_b/parsing.c Normal file
View File

@@ -0,0 +1,79 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 10:30:27 by dgaillet #+# #+# */
/* Updated: 2025/12/16 11:51:22 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc05.h"
#include "get_next_char.h"
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
static t_range *new_range(char *str)
{
t_range *range;
range = malloc(sizeof(t_range));
if (!range)
return (NULL);
range->start = atoll(str);
range->end = atoll(strchr(str, '-') + 1);
range->next = NULL;
range->pre = NULL;
return (range);
}
static void range_add_back(t_range **lst, t_range *new)
{
t_range *temp;
if (!lst)
return ;
if (!(*lst))
*lst = new;
else
{
temp = *lst;
while (temp->next)
temp = temp->next;
temp->next = new;
new->pre = temp;
}
}
void lst_clear(t_range *lst)
{
t_range *temp;
while (lst)
{
temp = lst->next;
free(lst);
lst = temp;
}
}
t_range *parsing(int fd)
{
t_range *lst = NULL;
char *temp;
temp = get_next_char(fd, '\n');
while (temp && strlen(temp) > 1)
{
range_add_back(&lst, new_range(temp));
free(temp);
temp = get_next_char(fd, '\n');
}
if (temp)
free(temp);
return (lst);
}

26
06/aoc06.h Normal file
View File

@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aoc06.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 15:27:06 by dgaillet #+# #+# */
/* Updated: 2025/12/16 16:50:13 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef AOC06_H
# define AOC06_H
typedef struct s_lst
{
unsigned long long nbrs[4];
char sign;
void *next;
} t_lst;
t_lst *parsing(int fd);
void lst_clear(t_lst *lst);
#endif

5
06/input Normal file
View File

@@ -0,0 +1,5 @@
6 8 99 58 62 9 497 52 586 58 1728 786 46 6 39 445 44 9 2 65 738 741 66 23 656 18 83 87 75 929 693 2743 26 122 2 518 56 6779 934 19 96 65 7 791 8 9 261 5849 1 8 5 28 38 27 819 89 111 828 4993 241 255 249 27 256 71 31 8964 44 71 49 37 3368 28 586 53 7117 98 765 2 83 6 325 727 62 73 7 5238 37 431 9 3 358 7 727 94 7846 129 331 757 23 7 82 91 1 1 92 963 124 82 6 592 96 657 61 8 6 88 284 6465 1813 75 2198 1169 45 7 22 2 379 25 8858 74 5122 82 774 52 31 26 2 2 3 2 5 3697 27 129 9 4 44 99 874 68 21 86 77 1 456 29 785 72 132 558 645 14 38 13 14 15 16 8 5898 61 22 54 15 599 741 548 99 41 43 21 281 78 69 7 35 385 667 46 64 99 97 46 418 58 43 392 28 5 9754 4328 372 6156 79 88 5248 3 472 7 97 37 28 32 398 74 8979 396 229 168 338 68 3762 83 979 363 68 4277 111 8198 98 3 88 84 7867 483 465 938 36 85 28 57 28 15 123 95 148 4 798 75 2 85 8 964 648 6 21 38 7 62 75 258 374 42 65 61 94 595 6 342 56 65 3 64 999 1 9375 46 16 266 5 39 2 9848 2 1 2955 823 88 525 64 624 525 11 8 284 79 24 752 123 7 283 98 151 729 79 49 12 68 78 1824 196 8 246 8 519 97 182 16 7 295 68 69 5 96 8 5 47 5 92 5 66 11 79 863 2875 71 89 133 75 93 64 37 8 2846 4188 681 1 6 845 7 2255 246 71 347 77 25 355 225 569 53 17 61 257 5 476 3648 57 8 3 6 3 515 492 77 1 73 77 67 4 7 779 98 56 2 748 77 957 56 49 519 1285 64 748 45 19 7 26 5 8 86 11 3 295 62 151 123 3965 174 71 72 96 92 9 7 73 7927 368 72 722 494 16 88 21 495 5 7 9194 52 33 19 4267 36 1 54 55 66 76 94 8 51 78 538 7 3 67 78 63 2 722 97 484 4 4 6789 47 7677 176 5 1 3 722 28 44 51 87 27 22 8145 143 7 6816 679 76 9 22 936 163 372 93 878 93 6 52 981 54 53 99 9671 9954 45 9 22 833 26 787 8 45 6 88 48 6 988 5383 7 6 1 24 6 9 18 742 57 22 591 14 3 58 4 26 5 5647 55 796 23 84 35 36 54 8599 48 66 199 4 71 92 7 15 339 6 2883 19 18 29 75 172 87 49 64 514 127 29 4145 35 66 875 2959 6824 5 686 14 67 461 992 2498 2 1 98 7 628 3927 61 32 7 93 124 49 1 978 96 165 54 8 6 892 5 75 8341 939 1 344 77 173 85 5 727 565 71 664 6177 6725 9 275 245 5 34 884 787 427 36 63 81 4 13 7 8 24 64 61 2 326 2 333 7 19 97 234 93 41 74 196 9975 6 48 391 425 752 22 833 812 526 63 4397 98 55 362 57 21 37 687 181 194 4 4745 13 2 763 77 589 3 136 54 76 24 3596 73 48 8719 52 534 874 961 5 14 935 979 36 242 48 19 4255 46 18 55 8793 4 31 16 58 5 479 912 6313 793 94 2227 799 446 564 597 327 5 4 9 54 66 3 45 665 69 1 49 1 64 6653 51 431 894 2987 835 8 96 868 3419 34 1 88 91 4 65 41 834 129 51 69 937 5 58 52 166 496 592 72 34 915 892 47 294 257 893 79 699 183 54 92 52 89 34 9 358 14 34 43 7 66 863 691 6 432 661 998 73 831 98 1 878 77 15 46 37 69 362 744 5857 363 67 398 71 82 2 7 4655 39 2 721 64 431 168 962 296 3 871 16 5 824 51 98 6 1881 674 219 62 49 351 655 838 7 5499 93 2 92 41 42 73 87 675 621 45 987 21 678 55 95 19 93 516 288 32 87 6 11 88 12 5458 6 756 52 11 6 184 72 74 83 99 652 7 28 2 32 42 688 426 599 351 498 5 449 49 124 94 7 2241 257 624 9685 9 9617 58 27 77 77 82 3 67 91 61 34 7 889 65 67 5973 957 7 3 3493 776 61 5 447 9 5 25 536 854 43 21 69 717 65 13 656 2 27 652 8 56 85 73 133 587 177 9898 361 58 87 3988 9967 276 56 648 39 77 3255 849 493 51 314 992 29 261 3 181 15 9 536 4 8322 1993 62 94 865 11 56 816 28 58 1349 36 68 913 23 69 45 59 481 38 45 8 425 9 4 739 6 86 41 28 326 519 8 141 919 874 5 42 84 3 99 455 268 9 338 497 7875 893 614 88 64 158 2415 64
187 49 5422 49 75 874 545 23 151 27 745 152 176 1 64 252 76 54 78 49 991 858 376 35 193 68 24 27 98 651 323 6366 87 851 3 228 146 515 514 42 11 32 83 724 717 37 213 8115 2 9 82 87 212 191 95 41 737 762 2869 227 592 291 61 689 66 657 8899 89 68 43 39 578 32 537 74 2449 86 383 9 827 93 982 461 25 83 3 3563 19 851 35 52 798 35 767 17 9933 693 823 358 5992 8 75 92 2 7 77 614 83 23 2 335 173 552 81 5 9 483 277 5839 5663 64 2831 5168 74 7 52 95 341 32 9115 29 8431 9 65 36 37 43 25 99 43 8 44 8295 8799 714 31 9 677 48 164 955 49 8 75 65 133 66 367 91 245 564 115 392 69 58 92 19 54 66 827 67 81 79 86 119 165 688 68 43 18 29 552 53 1598 9 16 242 173 65 56 65 26 89 995 71 87 854 66 55 2842 3228 899 8899 55 148 792 1 981 47 33 21 25 88 951 44 6767 336 595 64 597 99 3676 99 615 116 174 9429 379 6684 26 44 17 511 2764 337 6842 653 89 79 89 367 33 15 73 21 966 5 458 7569 4539 71 86 734 594 7 23 94 6 93 7 651 536 361 676 21 5 779 44 953 58 52 745 82 347 263 9827 52 758 7722 53 9861 46 3154 14 415 9124 536 27 251 92 453 49 51 97 59 58 88 88 37 47 318 569 778 677 5598 83 81 85 44 2978 576 14 947 11 215 51 841 6574 53 42 36 71 4 25 6 22 91 9 22 2 9 87 63 871 7489 166 87 12 75 63 98 36 27 1562 8446 161 89 99 429 9 8757 761 84 241 29 16 766 622 837 25 42 329 924 554 192 4493 38 71 1 627 1 464 897 44 64 86 866 924 973 7 859 1398 55 81 881 47 695 671 229 1363 7337 62 332 85 25 6661 2 45 4 37 75 3 3324 174 58 97 5319 149 69 49 827 99 4 61 42 5472 325 97 627 334 6 41 84 111 4 29 5232 56 74 64 7517 88 76 26 459 81 72 29 78 32 49 863 8 2 75 72 28 26 551 56 197 49 147 6244 37 8456 929 13 92 1 12 37 66 51 57 54 66 2234 391 41 1647 384 27 6238 581 774 464 226 245 694 457 91 97 593 44 5 72 9498 4914 11 9 6 958 87 734 873 34 1 96 776 48 521 5887 8 58 768 91 98 9 81 992 78 46 862 71 3 965 76 52 9 3686 27 372 33 54 47 727 87 1135 33 622 877 696 516 79 44 54 289 27 2737 73 99 3128 8558 6 96 65 573 346 795 83 8997 45 69 763 6634 996 1 262 61 76 811 963 9473 1 4 79 25 858 2718 71 512 12 845 4191 93 945 5238 95 314 56 46 388 158 212 22 6139 697 53 12 32 558 94 65 919 737 5 19 4829 6725 89 547 524 535 464 33 291 296 11 76 17 4 84 5797 321 57 65 111 763 858 26 676 42 979 9299 43 64 53 476 563 6376 21 27 646 74 483 14 553 174 684 94 3785 83 55 928 161 21 11 852 85 2627 45 2934 47 87 644 1698 192 38 423 641 27 729 3473 94 896 2561 54 267 97 742 59 61 22 5128 13 353 35 35 6946 74 16 64 9454 28 86 75 38 3 134 425 135 734 72 9844 624 2815 766 875 656 72 23 589 832 28 39 357 496 639 634 19 549 744 6522 16 143 73 7159 223 3 73 969 9449 5 55 53 56 9 458 53 579 776 1 88 597 3 82 55 893 499 291 36 222 275 393 75 729 663 15 79 894 744 13 73 68 31 89 5 328 25 76 84 3 687 274 151 97 224 727 191 59 742 56 486 959 679 67 75 17 88 148 731 238 866 47 383 99 914 572 31 4957 858 1 239 42 326 886 255 541 38 443 76 41 983 93 82 8 1865 369 572 26 75 772 916 265 3 5227 36 987 66 477 56 89 96 992 327 47 611 37 649 86 36 46 39 28 66 59 588 2 13 43 47 7958 56 323 15 51 8 879 68 87 59 89 383 76 54 3 97 44 431 189 275 768 686 3 135 696 778 74 12 3469 491 688 46 3 46 55 94 528 437 23 5 69 17 55 27 91 151 86 85 5838 153 9 87 4687 934 26 3 333 35 23 444 871 589 69 958 221 642 64 56 859 4 36 351 44 715 59 39 124 388 616 2241 232 37 81 7773 5577 719 81 828 49 89 2357 967 343 36 558 685 72 738 6 758 692 2 888 89 825 1883 68 46 427 287 78 733 37 17 9574 88 32 678 19 748 83 48 535 63 47 277 978 8 2 658 5 64 77 88 232 6914 4 568 839 644 176 72 473 89 58 818 888 79 761 748 1748 293 657 92 87 895 7875 16
635 82 2573 27 43 218 479 38 721 23 678 998 158 24 46 713 92 88 15 98 28 121 896 8 647 6898 18 16 74 8 2767 194 47 8654 78 7418 5555 11 931 73 98 9 93 35 365 32 841 7793 35 83 47 8 193 814 99 86 982 433 724 755 739 651 13 222 17 7694 6457 45 67 84 5 149 46 68 75 4776 59 941 362 239 139 691 217 48 64 96 1173 11 824 131 631 366 95 977 57 7366 64 714 443 4482 18 64 537 66 99 25 283 55 29 21 33 637 2 73 9 23 166 544 6478 5522 28 7339 1419 11 34 13 66 961 12 8176 41 869 6 18 62 1 91 43 679 859 81 985 5379 6312 278 93 29 1613 68 34 522 98 9 4 864 438 271 548 87 127 755 259 981 72 49 45 92 5 78 492 55 98 173 23 5155 337 946 59 78 62 439 516 88 1655 53 35 972 823 12 165 24 79 6 917 3 61 487 12 63 598 9493 935 1427 22 278 782 26 593 25 834 83 83 5 846 13 8992 18 964 42 571 62 945 62 744 418 571 2773 396 1434 984 3999 32 592 8337 1611 9792 287 15 77 23 1482 685 72 17 61 858 897 671 8219 4965 34 44 567 45 18 83 63 1 72 8 322 6 614 587 16 1 782 72 24 9 14 671 27 73 298 3896 472 914 4558 23 9769 57 475 41 6754 765 177 96 483 291 732 9 4 934 16 314 63 44 6 18 989 364 45 12 7359 39 36 61 3 9182 39 34 24 578 461 62 391 4924 12 97 54 4 866 19 16 81 3876 7 75 34 8 84 72 395 5238 588 34 17 97 7819 96 21 339 4664 1145 28 22 79 15 8 8821 974 51 42 26 74 447 12 875 54 58 441 179 675 33 493 86 65 75 364 325 22 75 37 351 82 215 242 656 4 978 2394 73 59 382 86 338 488 7495 8248 4326 5 25 13 51 7373 5 88 41 47 67 1 4171 657 1 19 453 272 4 23 738 287 169 783 94 64 168 15 754 943 2 83 6 922 2 192 85 86 665 27 4128 23 91 75 328 55 98 41 32 412 93 996 93 96 52 77 8 77 482 21 546 839 232 778 89 3318 541 88 13 71 28 97 58 9687 93 78 37 4444 816 91 725 435 49 8573 688 42 848 259 234 45 922 939 94 389 28 4 24 7156 8616 85 26 2 348 61 66 744 32 8 56 926 88 456 767 43 451 665 328 865 57 8 798 62 72 97 87 8 2955 95 42 33 4533 78 28 283 97 46 336 86 9551 49 6693 395 133 259 55 12 39 89 47 9459 42 63 4433 6759 6 4 42 314 259 989 79 1961 39 11 28 879 943 44 176 286 968 682 2519 127 5 4 977 61 8 775 45 617 27 183 7789 59 399 1224 249 353 21 19 6856 294 3143 94 1272 6 81 8 17 216 49 62 2 426 3 47 6657 5965 58 579 98 515 698 99 11 818 88 2 29 5 9 4726 741 52 6 671 897 4 45 331 29 399 6719 48 52 67 739 878 9882 14 16 474 77 547 965 23 893 997 11 9537 191 25 627 236 9 87 645 7 6585 61 72 16 148 6252 6244 357 51 85 655 9 599 79 99 534 7951 981 867 6 112 97 89 4 8697 13 645 95 56 4342 89 58 864 6826 82 12 89 41 6 225 82 677 786 54 3885 363 8528 3 56 593 2625 66 758 128 44 37 3759 994 5825 148 76 547 872 5435 22 281 3 4143 64 87 39 945 7394 8 434 82 5 41 685 59 18 667 5 652 12 51 16 19 45 459 6712 69 565 39 257 25 695 8 23 83 275 177 15 58 88 14 5 43 38 22 16 41 1 465 451 186 84 232 723 482 12 741 36 733 366 2789 19 84 17 72 465 56 418 75 8749 465 65 722 395 847 562 235 59 536 61 216 36 228 863 274 985 64 43 79 41 69 137 393 278 797 6 5 22 151 657 94 512 634 528 83 524 66 31 92 474 617 91 731 13 37 99 35 799 316 23 44 48 367 5 83 58 925 8949 22 237 66 12 2 27 78 45 78 33 363 21 5 12 11 56 686 166 25 633 87 295 692 1366 44 38 71 772 87 285 47 92 31 198 86 981 629 15 175 788 17 4 73 162 648 53 88 543 927 71 29 6232 152 2 946 38 71 75 297 614 48 59 498 293 456 53 21 25 49 591 522 83 394 97 88 4674 983 783 839 618 29 591 382 4685 495 98 596 45 21 5379 37 712 43 45 6794 6 78 67 842 338 51 613 62 1 8949 96 956 329 6188 23 216 11 55 146 75 69 369 68 322 65 97 652 49 39 456 57 37 151 682 2 16 43 77 41 3587 81 228 314 293 187 35 319 35 73 886 656 933 461 739 4914 39 81 73 3 12 9256 1512
552 33 5463 92 88 798 629 66 514 25 95 977 587 84 82 58 77 83 36 26 2 3643 911 1 617 9999 34 85 24 1 2544 1 26 7296 67 1683 6376 15 9 3 9 9 26 2 452 14 346 245 53 86 44 4 736 696 43 82 5 86 495 89 62 42 7 43 2 6832 2951 7 12 82 9 391 78 57 6 979 58 724 522 795 8893 1 994 2 23 84 6937 4 448 241 422 146 58 445 63 1 27 814 148 1517 64 66 752 13 82 45 1 54 91 84 71 915 5 56 18 94 845 335 12 1 9 183 8825 52 86 9 52 536 29 4996 73 131 9 77 94 3 192 95 935 873 71 296 5435 9951 22 46 89 3419 6 9 883 94 3 7 451 81 141 22 86 8 488 754 718 23 65 1 32 1 61 61 93 25 9733 3 9881 1 621 52 4 14 335 4 2 6852 23 56 285 44 43 258 24 8 2 72 8 3 6 6 35 734 47 586 474 64 318 54 54 78 678 256 82 89 5 7 93 4627 1 96 3 1 57 9 11 936 483 382 291 288 72 488 1518 16 382 678 2329 5738 6 28 5 27 8221 187 6 31 23 46 495 7 6513 1633 52 385 31 78 5724 15 67 88 14 7 212 4 744 993 68 3 132 99 47 7 133 398 43 7 395 7978 1958 3196 9786 52 3316 84 28 33 6516 446 27 18 923 926 848 1 1 744 39 765 8 78 8 21 275 338 4 6 3373 57 35 74 4 9983 27 54 66 552 16 25 33 1972 45 61 43 5 322 7 46 77 5276 33 78 75 8 51 99 936 427 659 46 7 36 6948 38 81 569 2 936 2 12 11 1 65 561 368 75 4 9 53 75 87 239 7 1 7627 232 984 23 68 61 34 455 488 241 5 68 89 135 6 3576 247 357 73 84 3114 9 36 2 91 879 927 7669 3249 879 7 4 3 97 7664 4 89 79 73 24 61 1235 313 9 18 2 11 8 74 467 963 358 395 89 37 629 33 79 34 7 16 4 459 52 396 47 75 985 41 123 83 15 77 421 4 66 84 78 659 1 318 48 53 69 32 6 94 54 13 168 3482 836 5 27 869 45 118 86 86 68 16 48 2927 98 48 22 456 31 21 74 278 48 9737 559 22 775 11 157 8 525 146 9 38 44 6 38 452 4 91 87 5 53 7 1 196 9 95 42 319 31 64 39 98 195 681 454 931 49 1 928 75 51 17 58 49 1248 89 5 75 67 48 46 648 12 62 526 42 7626 7 3614 827 917 443 6 42 75 2 75 154 3 26 6492 3937 1 2 41 3749 129 932 9 2979 7 88 1 727 23 81 982 128 931 38 7434 959 54 74 128 98 4 27 18 8755 71 415 8452 13 741 4523 544 7 3 69 6959 384 4395 43 27 9 46 9 8 51 78 78 9 459 7 7 3389 63 359 635 8 356 367 84 25 672 1 7 48 28 2 9158 148 55 8 451 533 7 41 5 34 177 9591 28 42 1 672 439 5337 665 6 429 24 371 886 97 227 876 35 3148 363 61 5 975 5 2 27 2 4488 92 66 45 173 1416 7518 41 77 4 368 9 884 57 53 538 23 471 662 9 838 14 7 5 9968 35 56 53 86 857 58 77 388 4 24 74 5 22 21 456 9 5 3 33 759 455 9778 7 8 673 7933 69 285 898 28 84 6313 26 2558 5461 58 836 244 811 57 819 1 653 6 54 82 159 9915 3 189 64 4 12 284 42 5 87 9 981 76 45 45 21 53 62 8468 29 578 2 371 46 4 9 17 7 276 437 39 37 69 79 4 99 53 33 22 71 77 818 698 67 59 12 931 9 4 2 89 836 6 1761 18 64 92 7 544 81 111 3 7282 227 87 991 256 264 9 996 65 6 66 924 8 49 95 969 538 16 66 71 24 12 353 5 6 966 2 5 29 69 859 81 484 884 425 2 5419 17 48 96 2233 336 23 579 725 53 8 57 812 224 5 83 4 483 39 77 83 622 48 79 47 88 122 86 9 87 46 5 8 78 64 1 24 93 23 729 25 95 211 35 445 16 5392 14 3 21 41 48 98 97 68 78 281 32 725 864 8 826 544 14 4 37 2471 144 64 78 89 97 16 52 8474 634 9 137 99 33 21 9136 58 25 47 687 741 694 18 88 66 94 671 217 33 195 44 95 3455 64 733 445 63 9 512 7 281 619 83 56 17 4 66 9 658 84 82 7319 7 5 624 57 245 887 57 18 3 2752 29 163 2 6789 82 248 4 93 799 44 91 74 4 735 985 92 71 85 86 778 36 79 368 853 56 22 85 6 1 5977 33 484 2737 2 724 58 626 46 41 65 71 454 733 923 97 13 3 1 9 81 1141 8719
* * + + + * * * + + + + + * * * + * + * * + * + * + * + * + + + + + + + + + * * * * * + * + + + + * + * + + + * + + + + * + * + * + + + * * + + * * * + + * * * + * + + * + + + + + * * * * * + + * + + * * + + * * + + * + * * * + * + * * + + * + + + * * * * * + * + + * * + + * * + * * + + + + * + * * * * + + * * * * + * * * * * * * * + * + * * + + + + + + * * * * * + + * + * * * + * * + + + * * * + + * + * + + * + * * * * * + * + + * * * + + * + + + + + + * + * * + + + * * * * + * * + * * * * + + * * + * + * * * + + + * + * + * * * + + * * + * * + + + + * + * + + + + + * + * * + * * * + * * + * * + + * + * + + * + * * * * + + * + + + + + + * + * + + + + * * * * + * * * * + * * + + + * + * + * + + + * * * * * * * * + + * * + * + * + + + * + * + + + * * + + * + * * + + + + + * * * * + * * * * + * + + + + + + + * + * + + + + * + * + * * * + * + + * * * + + * + + * + * * * + * * * + * * * + * + + + + * + * + * * * * + + + + + + + * + * + + * + * * * + + * * + + + + + + + + + * * * * + * * * + * + * * * * * * + + * * + * + + * + * + * + + * * * + + * + * * + * + * * * + + * + + * * + + * * + + * * * + + + * + + * + + * + + * * + + + + + + + * + * + * * + * + * + * * + * + + * * + + * + + + + * + + * + * * * + + * + * * * + + + * + + + + * + + * * + * * * * + * * * + * + + + + * + + + + + * + + * + + + + * * * * + + + + + * + * * + + + + + * * + * * * + * + + * * + * + * * + * + + + + + + + * + * + * + + + * * + * * + + + + + * + * + + * + * * * * * + + * + + + + + + * + * + + + * * + * * + + + * * + + * * * + * + + * * * + * * * * + * + + * * * + * + + * * + * + + + * + * + * + + + * * * * + + + + * * * * + * * + + + + + * + * + + * * * + + * * * * * * + + * + * + + * * * * * * * + + * * * + + + + * * + + * * + * * + + + * + * + * * * * * * + * + + + + + * + + + * + * * * * * + + * + * * * * * * + * * + * + + * + + * + + * + + + * + * * + + * * + * + + + * * * * + * + + * * + + * + * + + * * * * * + * + + * + + * * * * * * + * + + + + * + + * * + * * * * + + + * + * * + +

45
06/main.c Normal file
View File

@@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 15:07:02 by dgaillet #+# #+# */
/* Updated: 2025/12/16 16:50:46 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc06.h"
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
// 55755415012 ; to low
unsigned long long calculate_res(t_lst *lst)
{
unsigned long long res;
if (!lst)
return (0);
if (lst->sign == '+')
res = lst->nbrs[0] + lst->nbrs[1] + lst->nbrs[2] + lst->nbrs[3];
if (lst->sign == '*')
res = lst->nbrs[0] * lst->nbrs[1] * lst->nbrs[2] * lst->nbrs[3];
printf("%llu %c %llu %c %llu %c %llu = ", lst->nbrs[0], lst->sign, lst->nbrs[1], lst->sign, lst->nbrs[2], lst->sign, lst->nbrs[3]);
printf("%llu\n", res);
return (res + calculate_res(lst->next));
}
int main(void)
{
int fd = open("input", O_RDONLY);
t_lst *lst = parsing(fd);
unsigned long long res = 0;
res = calculate_res(lst);
lst_clear(lst);
close (fd);
printf("%llu\n", res);
}

123
06/parsing.c Normal file
View File

@@ -0,0 +1,123 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 16:03:38 by dgaillet #+# #+# */
/* Updated: 2025/12/16 16:50:23 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc06.h"
#include "libft.h"
#include "get_next_char.h"
#include <stdlib.h>
#include <stdio.h>
static t_lst *new_lst(void)
{
t_lst *lst;
lst = malloc(sizeof(t_lst));
if (!lst)
return (NULL);
lst->sign = '\0';
lst->next = NULL;
return (lst);
}
static void lst_add_back(t_lst **lst, t_lst *new)
{
t_lst *temp;
if (!lst)
return ;
if (!(*lst))
*lst = new;
else
{
temp = *lst;
while (temp->next)
temp = temp->next;
temp->next = new;
}
}
void lst_clear(t_lst *lst)
{
t_lst *temp;
while (lst)
{
temp = lst->next;
free(lst);
lst = temp;
}
}
static void add_nbr(t_lst *lst, char **nbrs, int i)
{
int j = 0;
while (nbrs[j])
{
lst->nbrs[i] = atoll(nbrs[j]);
j++;
lst = lst->next;
}
}
static void add_sign(t_lst *lst, char **signs)
{
int j = 0;
while (lst)
{
printf("%s\n", signs[j]);
lst->sign = signs[j][0];
j++;
lst = lst->next;
}
}
static void clear_split(char **tabs)
{
int i = 0;
while (tabs[i])
{
free(tabs[i]);
i++;
}
free(tabs);
}
t_lst *parsing(int fd)
{
char *temp;
char **int_lst;
int i = 0;
t_lst *lst = NULL;
temp = get_next_char(fd, '\n');
int_lst = ft_split(temp, ' ');
while (int_lst[i++])
lst_add_back(&lst, new_lst());
i = 0;
while (int_lst && ft_isdigit(int_lst[0][0]))
{
add_nbr(lst, int_lst, i);
i++;
free(temp);
clear_split(int_lst);
temp = get_next_char(fd, '\n');
int_lst = ft_split(temp, ' ');
}
printf("%s\n", temp);
printf("%s\n", int_lst[0]);
add_sign(lst, int_lst);
free(temp);
clear_split(int_lst);
return (lst);
}

27
06_b/aoc06.h Normal file
View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aoc06.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 15:27:06 by dgaillet #+# #+# */
/* Updated: 2025/12/16 20:06:30 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef AOC06_H
# define AOC06_H
typedef struct s_lst
{
char nbrs[5][5];
char sign;
void *next;
void *pre;
} t_lst;
t_lst *parsing(int fd);
void lst_clear(t_lst *lst);
#endif

5
06_b/example Normal file
View File

@@ -0,0 +1,5 @@
123 328 51 64
45 64 387 23
6 98 215 314
1 4 729 45
* + * +

5
06_b/input Normal file
View File

@@ -0,0 +1,5 @@
6 8 99 58 62 9 497 52 586 58 1728 786 46 6 39 445 44 9 2 65 738 741 66 23 656 18 83 87 75 929 693 2743 26 122 2 518 56 6779 934 19 96 65 7 791 8 9 261 5849 1 8 5 28 38 27 819 89 111 828 4993 241 255 249 27 256 71 31 8964 44 71 49 37 3368 28 586 53 7117 98 765 2 83 6 325 727 62 73 7 5238 37 431 9 3 358 7 727 94 7846 129 331 757 23 7 82 91 1 1 92 963 124 82 6 592 96 657 61 8 6 88 284 6465 1813 75 2198 1169 45 7 22 2 379 25 8858 74 5122 82 774 52 31 26 2 2 3 2 5 3697 27 129 9 4 44 99 874 68 21 86 77 1 456 29 785 72 132 558 645 14 38 13 14 15 16 8 5898 61 22 54 15 599 741 548 99 41 43 21 281 78 69 7 35 385 667 46 64 99 97 46 418 58 43 392 28 5 9754 4328 372 6156 79 88 5248 3 472 7 97 37 28 32 398 74 8979 396 229 168 338 68 3762 83 979 363 68 4277 111 8198 98 3 88 84 7867 483 465 938 36 85 28 57 28 15 123 95 148 4 798 75 2 85 8 964 648 6 21 38 7 62 75 258 374 42 65 61 94 595 6 342 56 65 3 64 999 1 9375 46 16 266 5 39 2 9848 2 1 2955 823 88 525 64 624 525 11 8 284 79 24 752 123 7 283 98 151 729 79 49 12 68 78 1824 196 8 246 8 519 97 182 16 7 295 68 69 5 96 8 5 47 5 92 5 66 11 79 863 2875 71 89 133 75 93 64 37 8 2846 4188 681 1 6 845 7 2255 246 71 347 77 25 355 225 569 53 17 61 257 5 476 3648 57 8 3 6 3 515 492 77 1 73 77 67 4 7 779 98 56 2 748 77 957 56 49 519 1285 64 748 45 19 7 26 5 8 86 11 3 295 62 151 123 3965 174 71 72 96 92 9 7 73 7927 368 72 722 494 16 88 21 495 5 7 9194 52 33 19 4267 36 1 54 55 66 76 94 8 51 78 538 7 3 67 78 63 2 722 97 484 4 4 6789 47 7677 176 5 1 3 722 28 44 51 87 27 22 8145 143 7 6816 679 76 9 22 936 163 372 93 878 93 6 52 981 54 53 99 9671 9954 45 9 22 833 26 787 8 45 6 88 48 6 988 5383 7 6 1 24 6 9 18 742 57 22 591 14 3 58 4 26 5 5647 55 796 23 84 35 36 54 8599 48 66 199 4 71 92 7 15 339 6 2883 19 18 29 75 172 87 49 64 514 127 29 4145 35 66 875 2959 6824 5 686 14 67 461 992 2498 2 1 98 7 628 3927 61 32 7 93 124 49 1 978 96 165 54 8 6 892 5 75 8341 939 1 344 77 173 85 5 727 565 71 664 6177 6725 9 275 245 5 34 884 787 427 36 63 81 4 13 7 8 24 64 61 2 326 2 333 7 19 97 234 93 41 74 196 9975 6 48 391 425 752 22 833 812 526 63 4397 98 55 362 57 21 37 687 181 194 4 4745 13 2 763 77 589 3 136 54 76 24 3596 73 48 8719 52 534 874 961 5 14 935 979 36 242 48 19 4255 46 18 55 8793 4 31 16 58 5 479 912 6313 793 94 2227 799 446 564 597 327 5 4 9 54 66 3 45 665 69 1 49 1 64 6653 51 431 894 2987 835 8 96 868 3419 34 1 88 91 4 65 41 834 129 51 69 937 5 58 52 166 496 592 72 34 915 892 47 294 257 893 79 699 183 54 92 52 89 34 9 358 14 34 43 7 66 863 691 6 432 661 998 73 831 98 1 878 77 15 46 37 69 362 744 5857 363 67 398 71 82 2 7 4655 39 2 721 64 431 168 962 296 3 871 16 5 824 51 98 6 1881 674 219 62 49 351 655 838 7 5499 93 2 92 41 42 73 87 675 621 45 987 21 678 55 95 19 93 516 288 32 87 6 11 88 12 5458 6 756 52 11 6 184 72 74 83 99 652 7 28 2 32 42 688 426 599 351 498 5 449 49 124 94 7 2241 257 624 9685 9 9617 58 27 77 77 82 3 67 91 61 34 7 889 65 67 5973 957 7 3 3493 776 61 5 447 9 5 25 536 854 43 21 69 717 65 13 656 2 27 652 8 56 85 73 133 587 177 9898 361 58 87 3988 9967 276 56 648 39 77 3255 849 493 51 314 992 29 261 3 181 15 9 536 4 8322 1993 62 94 865 11 56 816 28 58 1349 36 68 913 23 69 45 59 481 38 45 8 425 9 4 739 6 86 41 28 326 519 8 141 919 874 5 42 84 3 99 455 268 9 338 497 7875 893 614 88 64 158 2415 64
187 49 5422 49 75 874 545 23 151 27 745 152 176 1 64 252 76 54 78 49 991 858 376 35 193 68 24 27 98 651 323 6366 87 851 3 228 146 515 514 42 11 32 83 724 717 37 213 8115 2 9 82 87 212 191 95 41 737 762 2869 227 592 291 61 689 66 657 8899 89 68 43 39 578 32 537 74 2449 86 383 9 827 93 982 461 25 83 3 3563 19 851 35 52 798 35 767 17 9933 693 823 358 5992 8 75 92 2 7 77 614 83 23 2 335 173 552 81 5 9 483 277 5839 5663 64 2831 5168 74 7 52 95 341 32 9115 29 8431 9 65 36 37 43 25 99 43 8 44 8295 8799 714 31 9 677 48 164 955 49 8 75 65 133 66 367 91 245 564 115 392 69 58 92 19 54 66 827 67 81 79 86 119 165 688 68 43 18 29 552 53 1598 9 16 242 173 65 56 65 26 89 995 71 87 854 66 55 2842 3228 899 8899 55 148 792 1 981 47 33 21 25 88 951 44 6767 336 595 64 597 99 3676 99 615 116 174 9429 379 6684 26 44 17 511 2764 337 6842 653 89 79 89 367 33 15 73 21 966 5 458 7569 4539 71 86 734 594 7 23 94 6 93 7 651 536 361 676 21 5 779 44 953 58 52 745 82 347 263 9827 52 758 7722 53 9861 46 3154 14 415 9124 536 27 251 92 453 49 51 97 59 58 88 88 37 47 318 569 778 677 5598 83 81 85 44 2978 576 14 947 11 215 51 841 6574 53 42 36 71 4 25 6 22 91 9 22 2 9 87 63 871 7489 166 87 12 75 63 98 36 27 1562 8446 161 89 99 429 9 8757 761 84 241 29 16 766 622 837 25 42 329 924 554 192 4493 38 71 1 627 1 464 897 44 64 86 866 924 973 7 859 1398 55 81 881 47 695 671 229 1363 7337 62 332 85 25 6661 2 45 4 37 75 3 3324 174 58 97 5319 149 69 49 827 99 4 61 42 5472 325 97 627 334 6 41 84 111 4 29 5232 56 74 64 7517 88 76 26 459 81 72 29 78 32 49 863 8 2 75 72 28 26 551 56 197 49 147 6244 37 8456 929 13 92 1 12 37 66 51 57 54 66 2234 391 41 1647 384 27 6238 581 774 464 226 245 694 457 91 97 593 44 5 72 9498 4914 11 9 6 958 87 734 873 34 1 96 776 48 521 5887 8 58 768 91 98 9 81 992 78 46 862 71 3 965 76 52 9 3686 27 372 33 54 47 727 87 1135 33 622 877 696 516 79 44 54 289 27 2737 73 99 3128 8558 6 96 65 573 346 795 83 8997 45 69 763 6634 996 1 262 61 76 811 963 9473 1 4 79 25 858 2718 71 512 12 845 4191 93 945 5238 95 314 56 46 388 158 212 22 6139 697 53 12 32 558 94 65 919 737 5 19 4829 6725 89 547 524 535 464 33 291 296 11 76 17 4 84 5797 321 57 65 111 763 858 26 676 42 979 9299 43 64 53 476 563 6376 21 27 646 74 483 14 553 174 684 94 3785 83 55 928 161 21 11 852 85 2627 45 2934 47 87 644 1698 192 38 423 641 27 729 3473 94 896 2561 54 267 97 742 59 61 22 5128 13 353 35 35 6946 74 16 64 9454 28 86 75 38 3 134 425 135 734 72 9844 624 2815 766 875 656 72 23 589 832 28 39 357 496 639 634 19 549 744 6522 16 143 73 7159 223 3 73 969 9449 5 55 53 56 9 458 53 579 776 1 88 597 3 82 55 893 499 291 36 222 275 393 75 729 663 15 79 894 744 13 73 68 31 89 5 328 25 76 84 3 687 274 151 97 224 727 191 59 742 56 486 959 679 67 75 17 88 148 731 238 866 47 383 99 914 572 31 4957 858 1 239 42 326 886 255 541 38 443 76 41 983 93 82 8 1865 369 572 26 75 772 916 265 3 5227 36 987 66 477 56 89 96 992 327 47 611 37 649 86 36 46 39 28 66 59 588 2 13 43 47 7958 56 323 15 51 8 879 68 87 59 89 383 76 54 3 97 44 431 189 275 768 686 3 135 696 778 74 12 3469 491 688 46 3 46 55 94 528 437 23 5 69 17 55 27 91 151 86 85 5838 153 9 87 4687 934 26 3 333 35 23 444 871 589 69 958 221 642 64 56 859 4 36 351 44 715 59 39 124 388 616 2241 232 37 81 7773 5577 719 81 828 49 89 2357 967 343 36 558 685 72 738 6 758 692 2 888 89 825 1883 68 46 427 287 78 733 37 17 9574 88 32 678 19 748 83 48 535 63 47 277 978 8 2 658 5 64 77 88 232 6914 4 568 839 644 176 72 473 89 58 818 888 79 761 748 1748 293 657 92 87 895 7875 16
635 82 2573 27 43 218 479 38 721 23 678 998 158 24 46 713 92 88 15 98 28 121 896 8 647 6898 18 16 74 8 2767 194 47 8654 78 7418 5555 11 931 73 98 9 93 35 365 32 841 7793 35 83 47 8 193 814 99 86 982 433 724 755 739 651 13 222 17 7694 6457 45 67 84 5 149 46 68 75 4776 59 941 362 239 139 691 217 48 64 96 1173 11 824 131 631 366 95 977 57 7366 64 714 443 4482 18 64 537 66 99 25 283 55 29 21 33 637 2 73 9 23 166 544 6478 5522 28 7339 1419 11 34 13 66 961 12 8176 41 869 6 18 62 1 91 43 679 859 81 985 5379 6312 278 93 29 1613 68 34 522 98 9 4 864 438 271 548 87 127 755 259 981 72 49 45 92 5 78 492 55 98 173 23 5155 337 946 59 78 62 439 516 88 1655 53 35 972 823 12 165 24 79 6 917 3 61 487 12 63 598 9493 935 1427 22 278 782 26 593 25 834 83 83 5 846 13 8992 18 964 42 571 62 945 62 744 418 571 2773 396 1434 984 3999 32 592 8337 1611 9792 287 15 77 23 1482 685 72 17 61 858 897 671 8219 4965 34 44 567 45 18 83 63 1 72 8 322 6 614 587 16 1 782 72 24 9 14 671 27 73 298 3896 472 914 4558 23 9769 57 475 41 6754 765 177 96 483 291 732 9 4 934 16 314 63 44 6 18 989 364 45 12 7359 39 36 61 3 9182 39 34 24 578 461 62 391 4924 12 97 54 4 866 19 16 81 3876 7 75 34 8 84 72 395 5238 588 34 17 97 7819 96 21 339 4664 1145 28 22 79 15 8 8821 974 51 42 26 74 447 12 875 54 58 441 179 675 33 493 86 65 75 364 325 22 75 37 351 82 215 242 656 4 978 2394 73 59 382 86 338 488 7495 8248 4326 5 25 13 51 7373 5 88 41 47 67 1 4171 657 1 19 453 272 4 23 738 287 169 783 94 64 168 15 754 943 2 83 6 922 2 192 85 86 665 27 4128 23 91 75 328 55 98 41 32 412 93 996 93 96 52 77 8 77 482 21 546 839 232 778 89 3318 541 88 13 71 28 97 58 9687 93 78 37 4444 816 91 725 435 49 8573 688 42 848 259 234 45 922 939 94 389 28 4 24 7156 8616 85 26 2 348 61 66 744 32 8 56 926 88 456 767 43 451 665 328 865 57 8 798 62 72 97 87 8 2955 95 42 33 4533 78 28 283 97 46 336 86 9551 49 6693 395 133 259 55 12 39 89 47 9459 42 63 4433 6759 6 4 42 314 259 989 79 1961 39 11 28 879 943 44 176 286 968 682 2519 127 5 4 977 61 8 775 45 617 27 183 7789 59 399 1224 249 353 21 19 6856 294 3143 94 1272 6 81 8 17 216 49 62 2 426 3 47 6657 5965 58 579 98 515 698 99 11 818 88 2 29 5 9 4726 741 52 6 671 897 4 45 331 29 399 6719 48 52 67 739 878 9882 14 16 474 77 547 965 23 893 997 11 9537 191 25 627 236 9 87 645 7 6585 61 72 16 148 6252 6244 357 51 85 655 9 599 79 99 534 7951 981 867 6 112 97 89 4 8697 13 645 95 56 4342 89 58 864 6826 82 12 89 41 6 225 82 677 786 54 3885 363 8528 3 56 593 2625 66 758 128 44 37 3759 994 5825 148 76 547 872 5435 22 281 3 4143 64 87 39 945 7394 8 434 82 5 41 685 59 18 667 5 652 12 51 16 19 45 459 6712 69 565 39 257 25 695 8 23 83 275 177 15 58 88 14 5 43 38 22 16 41 1 465 451 186 84 232 723 482 12 741 36 733 366 2789 19 84 17 72 465 56 418 75 8749 465 65 722 395 847 562 235 59 536 61 216 36 228 863 274 985 64 43 79 41 69 137 393 278 797 6 5 22 151 657 94 512 634 528 83 524 66 31 92 474 617 91 731 13 37 99 35 799 316 23 44 48 367 5 83 58 925 8949 22 237 66 12 2 27 78 45 78 33 363 21 5 12 11 56 686 166 25 633 87 295 692 1366 44 38 71 772 87 285 47 92 31 198 86 981 629 15 175 788 17 4 73 162 648 53 88 543 927 71 29 6232 152 2 946 38 71 75 297 614 48 59 498 293 456 53 21 25 49 591 522 83 394 97 88 4674 983 783 839 618 29 591 382 4685 495 98 596 45 21 5379 37 712 43 45 6794 6 78 67 842 338 51 613 62 1 8949 96 956 329 6188 23 216 11 55 146 75 69 369 68 322 65 97 652 49 39 456 57 37 151 682 2 16 43 77 41 3587 81 228 314 293 187 35 319 35 73 886 656 933 461 739 4914 39 81 73 3 12 9256 1512
552 33 5463 92 88 798 629 66 514 25 95 977 587 84 82 58 77 83 36 26 2 3643 911 1 617 9999 34 85 24 1 2544 1 26 7296 67 1683 6376 15 9 3 9 9 26 2 452 14 346 245 53 86 44 4 736 696 43 82 5 86 495 89 62 42 7 43 2 6832 2951 7 12 82 9 391 78 57 6 979 58 724 522 795 8893 1 994 2 23 84 6937 4 448 241 422 146 58 445 63 1 27 814 148 1517 64 66 752 13 82 45 1 54 91 84 71 915 5 56 18 94 845 335 12 1 9 183 8825 52 86 9 52 536 29 4996 73 131 9 77 94 3 192 95 935 873 71 296 5435 9951 22 46 89 3419 6 9 883 94 3 7 451 81 141 22 86 8 488 754 718 23 65 1 32 1 61 61 93 25 9733 3 9881 1 621 52 4 14 335 4 2 6852 23 56 285 44 43 258 24 8 2 72 8 3 6 6 35 734 47 586 474 64 318 54 54 78 678 256 82 89 5 7 93 4627 1 96 3 1 57 9 11 936 483 382 291 288 72 488 1518 16 382 678 2329 5738 6 28 5 27 8221 187 6 31 23 46 495 7 6513 1633 52 385 31 78 5724 15 67 88 14 7 212 4 744 993 68 3 132 99 47 7 133 398 43 7 395 7978 1958 3196 9786 52 3316 84 28 33 6516 446 27 18 923 926 848 1 1 744 39 765 8 78 8 21 275 338 4 6 3373 57 35 74 4 9983 27 54 66 552 16 25 33 1972 45 61 43 5 322 7 46 77 5276 33 78 75 8 51 99 936 427 659 46 7 36 6948 38 81 569 2 936 2 12 11 1 65 561 368 75 4 9 53 75 87 239 7 1 7627 232 984 23 68 61 34 455 488 241 5 68 89 135 6 3576 247 357 73 84 3114 9 36 2 91 879 927 7669 3249 879 7 4 3 97 7664 4 89 79 73 24 61 1235 313 9 18 2 11 8 74 467 963 358 395 89 37 629 33 79 34 7 16 4 459 52 396 47 75 985 41 123 83 15 77 421 4 66 84 78 659 1 318 48 53 69 32 6 94 54 13 168 3482 836 5 27 869 45 118 86 86 68 16 48 2927 98 48 22 456 31 21 74 278 48 9737 559 22 775 11 157 8 525 146 9 38 44 6 38 452 4 91 87 5 53 7 1 196 9 95 42 319 31 64 39 98 195 681 454 931 49 1 928 75 51 17 58 49 1248 89 5 75 67 48 46 648 12 62 526 42 7626 7 3614 827 917 443 6 42 75 2 75 154 3 26 6492 3937 1 2 41 3749 129 932 9 2979 7 88 1 727 23 81 982 128 931 38 7434 959 54 74 128 98 4 27 18 8755 71 415 8452 13 741 4523 544 7 3 69 6959 384 4395 43 27 9 46 9 8 51 78 78 9 459 7 7 3389 63 359 635 8 356 367 84 25 672 1 7 48 28 2 9158 148 55 8 451 533 7 41 5 34 177 9591 28 42 1 672 439 5337 665 6 429 24 371 886 97 227 876 35 3148 363 61 5 975 5 2 27 2 4488 92 66 45 173 1416 7518 41 77 4 368 9 884 57 53 538 23 471 662 9 838 14 7 5 9968 35 56 53 86 857 58 77 388 4 24 74 5 22 21 456 9 5 3 33 759 455 9778 7 8 673 7933 69 285 898 28 84 6313 26 2558 5461 58 836 244 811 57 819 1 653 6 54 82 159 9915 3 189 64 4 12 284 42 5 87 9 981 76 45 45 21 53 62 8468 29 578 2 371 46 4 9 17 7 276 437 39 37 69 79 4 99 53 33 22 71 77 818 698 67 59 12 931 9 4 2 89 836 6 1761 18 64 92 7 544 81 111 3 7282 227 87 991 256 264 9 996 65 6 66 924 8 49 95 969 538 16 66 71 24 12 353 5 6 966 2 5 29 69 859 81 484 884 425 2 5419 17 48 96 2233 336 23 579 725 53 8 57 812 224 5 83 4 483 39 77 83 622 48 79 47 88 122 86 9 87 46 5 8 78 64 1 24 93 23 729 25 95 211 35 445 16 5392 14 3 21 41 48 98 97 68 78 281 32 725 864 8 826 544 14 4 37 2471 144 64 78 89 97 16 52 8474 634 9 137 99 33 21 9136 58 25 47 687 741 694 18 88 66 94 671 217 33 195 44 95 3455 64 733 445 63 9 512 7 281 619 83 56 17 4 66 9 658 84 82 7319 7 5 624 57 245 887 57 18 3 2752 29 163 2 6789 82 248 4 93 799 44 91 74 4 735 985 92 71 85 86 778 36 79 368 853 56 22 85 6 1 5977 33 484 2737 2 724 58 626 46 41 65 71 454 733 923 97 13 3 1 9 81 1141 8719
* * + + + * * * + + + + + * * * + * + * * + * + * + * + * + + + + + + + + + * * * * * + * + + + + * + * + + + * + + + + * + * + * + + + * * + + * * * + + * * * + * + + * + + + + + * * * * * + + * + + * * + + * * + + * + * * * + * + * * + + * + + + * * * * * + * + + * * + + * * + * * + + + + * + * * * * + + * * * * + * * * * * * * * + * + * * + + + + + + * * * * * + + * + * * * + * * + + + * * * + + * + * + + * + * * * * * + * + + * * * + + * + + + + + + * + * * + + + * * * * + * * + * * * * + + * * + * + * * * + + + * + * + * * * + + * * + * * + + + + * + * + + + + + * + * * + * * * + * * + * * + + * + * + + * + * * * * + + * + + + + + + * + * + + + + * * * * + * * * * + * * + + + * + * + * + + + * * * * * * * * + + * * + * + * + + + * + * + + + * * + + * + * * + + + + + * * * * + * * * * + * + + + + + + + * + * + + + + * + * + * * * + * + + * * * + + * + + * + * * * + * * * + * * * + * + + + + * + * + * * * * + + + + + + + * + * + + * + * * * + + * * + + + + + + + + + * * * * + * * * + * + * * * * * * + + * * + * + + * + * + * + + * * * + + * + * * + * + * * * + + * + + * * + + * * + + * * * + + + * + + * + + * + + * * + + + + + + + * + * + * * + * + * + * * + * + + * * + + * + + + + * + + * + * * * + + * + * * * + + + * + + + + * + + * * + * * * * + * * * + * + + + + * + + + + + * + + * + + + + * * * * + + + + + * + * * + + + + + * * + * * * + * + + * * + * + * * + * + + + + + + + * + * + * + + + * * + * * + + + + + * + * + + * + * * * * * + + * + + + + + + * + * + + + * * + * * + + + * * + + * * * + * + + * * * + * * * * + * + + * * * + * + + * * + * + + + * + * + * + + + * * * * + + + + * * * * + * * + + + + + * + * + + * * * + + * * * * * * + + * + * + + * * * * * * * + + * * * + + + + * * + + * * + * * + + + * + * + * * * * * * + * + + + + + * + + + * + * * * * * + + * + * * * * * * + * * + * + + * + + * + + * + + + * + * * + + * * + * + + + * * * * + * + + * * + + * + * + + * * * * * + * + + * + + * * * * * * + * + + + + * + + * * + * * * * + + + * + * * + +

71
06_b/main.c Normal file
View File

@@ -0,0 +1,71 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 15:07:02 by dgaillet #+# #+# */
/* Updated: 2025/12/17 14:22:46 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc06.h"
#include "libft.h"
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
// 21981441218167856 ; to high
unsigned long long calculate_res(t_lst *lst)
{
unsigned long long res = 0;
int temp[4] = {0, 0, 0, 0};
int i;
int j;
if (!lst)
return (0);
j = 0;
while (j < 4)
{
temp[j] = 0;
i = 0;
while (lst->nbrs[i][j])
{
if (ft_isdigit(lst->nbrs[i][j]))
temp[j] = (10 * temp[j]) + (lst->nbrs[i][j] - '0');
i++;
}
j++;
}
j = 0;
if (lst->sign == '*')
res = 1;
while (j < 4)
{
if (temp[j])
{
if (lst->sign == '+')
res += temp[j];
if (lst->sign == '*')
res *= temp[j];
}
j++;
}
printf("%llu\n", res);
return (res + calculate_res(lst->pre));
}
int main(void)
{
int fd = open("input", O_RDONLY);
t_lst *lst = parsing(fd);
unsigned long long res = 0;
res = calculate_res(lst);
lst_clear(lst);
close (fd);
printf("%llu\n", res);
}

142
06_b/parsing.c Normal file
View File

@@ -0,0 +1,142 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/16 16:03:38 by dgaillet #+# #+# */
/* Updated: 2025/12/17 14:57:13 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc06.h"
#include "libft.h"
#include <string.h>
#include "get_next_char.h"
#include <stdlib.h>
#include <stdio.h>
// 5391396 ; to low
static t_lst *new_lst(void)
{
t_lst *lst;
lst = malloc(sizeof(t_lst));
if (!lst)
return (NULL);
ft_bzero(lst->nbrs[0], 5);
ft_bzero(lst->nbrs[1], 5);
ft_bzero(lst->nbrs[2], 5);
ft_bzero(lst->nbrs[3], 5);
ft_bzero(lst->nbrs[4], 5);
lst->sign = '\0';
lst->next = NULL;
lst->pre = NULL;
return (lst);
}
static void lst_add_back(t_lst **lst, t_lst *new)
{
t_lst *temp;
if (!lst)
return ;
if (!(*lst))
*lst = new;
else
{
temp = *lst;
while (temp->next)
temp = temp->next;
temp->next = new;
new->pre = temp;
}
}
void lst_clear(t_lst *lst)
{
t_lst *temp;
while (lst)
{
temp = lst->next;
free(lst);
lst = temp;
}
}
static void add_sign(t_lst *lst, char **signs)
{
int j = 0;
while (lst)
{
printf("%s\n", signs[j]);
lst->sign = signs[j][0];
j++;
lst = lst->next;
}
}
static void add_nbr(char *strs[5], t_lst *lst, int i)
{
int j;
int k;
if (!lst)
return ;
k = 0;
while (i >= 0 && !(strs[0][i] == ' ' && strs[1][i] == ' ' && strs[2][i] == ' '
&& strs[3][i] == ' ' && strs[4][i] == ' '))
{
j = 0;
while (j < 4)
{
lst->nbrs[j][k] = strs[j][i];
j++;
}
k++;
i--;
}
add_nbr(strs, lst->pre, i - 1);
}
static void clear_split(char **tabs)
{
int i = 0;
while (tabs[i])
{
free(tabs[i]);
i++;
}
free(tabs);
}
t_lst *parsing(int fd)
{
char *temp[5];
char **int_lst = NULL;
int i = -1;
t_lst *lst = NULL;
temp[++i] = get_next_char(fd, '\n');
while (temp[i])
temp[++i] = get_next_char(fd, '\n');
int_lst = ft_split(temp[4], ' ');
i = 0;
while (int_lst[++i])
lst_add_back(&lst, new_lst());
clear_split(int_lst);
int_lst = ft_split(temp[4], ' ');
add_sign(lst, int_lst);
while (lst->next)
lst = lst->next;
add_nbr(temp, lst, strlen(temp[0]) - 2);
i = -1;
while (++i < 6)
free(temp[i]);
clear_split(int_lst);
return (lst);
}

142
07/input Normal file
View File

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

64
07/main.c Normal file
View File

@@ -0,0 +1,64 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/17 14:58:08 by dgaillet #+# #+# */
/* Updated: 2025/12/17 15:25:49 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
char **parsing(int fd);
static size_t nb_split(char **tab)
{
size_t nb_split = 0;
int i = 0;
int j;
while (tab[i])
{
j = 0;
while (tab[i][j])
{
if ((tab[i][j] == 'S' || tab[i][j] == '|' ) && tab[i + 1] && tab[i+1][j] != '^')
tab[i + 1][j] = '|';
else if (tab[i][j] == '^' && tab[i - 1][j] == '|')
{
tab[i][j + 1] = '|';
tab[i][j - 1] = '|';
if (tab[i + 1] && tab[i + 1][j + 1] != '^')
tab[i + 1][j + 1] = '|';
if (tab[i + 1] && tab[i + 1][j - 1] != '^')
tab[i + 1][j - 1] = '|';
nb_split++;
}
j++;
}
i++;
}
return (nb_split);
}
int main(void)
{
int fd = open("input", O_RDONLY);
char **tab = parsing(fd);
int i = 0;
printf("%zu\n", nb_split(tab));
while (tab[i])
{
free(tab[i]);
i++;
}
free(tab);
close(fd);
}

60
07/parsing.c Normal file
View File

@@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/17 15:02:13 by dgaillet #+# #+# */
/* Updated: 2025/12/17 15:29:54 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "get_next_char.h"
size_t tab_len(char **tab)
{
size_t i = 0;
if (!tab)
return (0);
while (tab[i])
i++;
return (i);
}
char **tab_extend(char **tab, char *str)
{
char **new_tab;
size_t i = 0;
size_t len = tab_len(tab);
new_tab = malloc(sizeof(char *) * (len + 2));
if (!new_tab)
return (NULL);
while (i < len)
{
new_tab[i] = tab[i];
i++;
}
new_tab[len] = str;
new_tab[len + 1] = NULL;
if (len > 0)
free(tab);
return (new_tab);
}
char **parsing(int fd)
{
char **tab = NULL;
char *temp;
temp = get_next_char(fd, '\n');
while (temp)
{
tab = tab_extend(tab, temp);
temp = get_next_char(fd, '\n');
}
return (tab);
}

16
07_b/example Normal file
View File

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

142
07_b/input Normal file
View File

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

137
07_b/main.c Normal file
View File

@@ -0,0 +1,137 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/17 14:58:08 by dgaillet #+# #+# */
/* Updated: 2025/12/17 17:35:52 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
char **parsing(size_t fd);
#define SIZE 142
static void fill_line(char **tab, size_t int_tab[SIZE][SIZE], size_t i)
{
int j = 0;
while (tab[i][j])
{
if (tab[i][j] == '|')
int_tab[i][j] = int_tab[i + 1][j];
j++;
}
j = 0;
while (tab[i][j])
{
if (tab[i][j] == '^')
int_tab[i][j] = int_tab[i][j + 1] + int_tab[i][j - 1];
j++;
}
printf(tab[i]);
for (int j = 0 ; j < SIZE ; j++) {
printf("%.1zu|", int_tab[i][j]);
}
printf("\n");
}
void print_int_tab(size_t int_tab[SIZE][SIZE]) {
for (int i = 0 ; i < SIZE ; i++) {
for (int j = 0 ; j < SIZE ; j++) {
printf("%.1zu|", int_tab[i][j]);
}
printf("\n");
}
}
static void nb_timeline(char **tab, size_t int_tab[SIZE][SIZE])
{
int j = 0;
while (tab[SIZE - 1][j])
{
if (tab[SIZE - 1][j] == '|')
int_tab[SIZE - 1][j] = 1;
else
int_tab[SIZE - 1][j] = 0;
j++;
}
j = SIZE - 2;
while (j > 0)
{
fill_line(tab, int_tab, j--);
}
print_int_tab(int_tab);
printf("%zu\n", int_tab[1][SIZE / 2]);
}
static void write_paths(char **tab)
{
int i = 0;
int j;
while (tab[i])
{
j = 0;
while (tab[i][j])
{
if ((tab[i][j] == 'S' || tab[i][j] == '|' ) && tab[i + 1] && tab[i+1][j] != '^')
tab[i + 1][j] = '|';
else if (tab[i][j] == '^' && tab[i - 1][j] == '|')
{
tab[i][j + 1] = '|';
tab[i][j - 1] = '|';
if (tab[i + 1] && tab[i + 1][j + 1] != '^')
tab[i + 1][j + 1] = '|';
if (tab[i + 1] && tab[i + 1][j - 1] != '^')
tab[i + 1][j - 1] = '|';
}
j++;
}
i++;
}
}
static void print_tab(char **tab)
{
int i = 0;
while (tab[i])
{
printf("%s", tab[i]);
i++;
}
}
int main(void)
{
int fd = open("input", O_RDONLY);
char **tab = parsing(fd);
int i = 0;
static size_t int_tab[SIZE][SIZE];
print_int_tab(int_tab);
write_paths(tab);
print_tab(tab);
while (tab[0][i] != 'S')
i++;
nb_timeline(tab, &int_tab);
i = 0;
while (tab[i])
{
free(tab[i]);
i++;
}
free(tab);
close(fd);
}

60
07_b/parsing.c Normal file
View File

@@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/17 15:02:13 by dgaillet #+# #+# */
/* Updated: 2025/12/17 15:29:54 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "get_next_char.h"
size_t tab_len(char **tab)
{
size_t i = 0;
if (!tab)
return (0);
while (tab[i])
i++;
return (i);
}
char **tab_extend(char **tab, char *str)
{
char **new_tab;
size_t i = 0;
size_t len = tab_len(tab);
new_tab = malloc(sizeof(char *) * (len + 2));
if (!new_tab)
return (NULL);
while (i < len)
{
new_tab[i] = tab[i];
i++;
}
new_tab[len] = str;
new_tab[len + 1] = NULL;
if (len > 0)
free(tab);
return (new_tab);
}
char **parsing(int fd)
{
char **tab = NULL;
char *temp;
temp = get_next_char(fd, '\n');
while (temp)
{
tab = tab_extend(tab, temp);
temp = get_next_char(fd, '\n');
}
return (tab);
}