This commit is contained in:
Tim Nope
2022-12-11 18:06:33 +01:00
commit 6b6fc8d486
1361 changed files with 19939 additions and 0 deletions

7
d08/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "d05"
version = "0.1.0"

8
d08/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "d05"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

99
d08/input.txt Normal file
View File

@ -0,0 +1,99 @@
001012002320230123321232210301123012330310002132422435543131011222140442223410333011301131030221102
210021010313032103103140242443030204041353523334411152343535155001331010424342400321222130332211000
220111020130022123343304003244321141423124554224223425242425411232310410220404123040022230232012001
110001322300033003110104022024431213325443435243534332232113223514234032203314213003023330320211122
222202032101012330012433332004525555532223225141422352121223513235241131140321304343032313200003010
010010110133111221201020242055234235524542112413124323131144113543431153434301004404433332201031101
010311122010234433300120311511522452111432234122525425223314414215442523431244211444442301123113210
003321302131404313000401541531451144531134434463243226554353531154535312341542344311140133323000112
200013031211204103423144434355141345154545346623525242363434345352211152134113324342444433323330130
213310112332433111423413354352345254466653452565433223363325455344211532114454334224403233310132111
301310132332122210134424334135423222423664623436246455422544342256623553153523514101223110412311222
003113122134234433143524345514234366646263266264553344546354446622442232321542525134320340224112030
111010014244141324135251513124424653233656466554233425634233622535556255353132241513243042230021232
220032130013434031522453151465445556326346445523225553334454232465325653331555325543240041133300011
101313441333324224231335545645533666222425623425435534222565234252324352343215322255453414332101210
002001011024205314542543462422652443265656353475764377536354633543522362354233434354131244430312211
130102432412053215215452523665226644223567657574374755564446457525256362523651434111251304121330431
003203204111231534515445625633555646344656347534357443663644347765225425526633323421252443134040242
204123142044135555223233536265353645677735477756344734474355556456564424435456361241242524143213243
331230114345353323336455253322335737365665434353644735736467454346456653343444462312145253343104043
322103024244354423354666446624446457777653554356674563737477465364743364642532635425334533522432420
032433200251224413566656253227564444673377443667557756334664377554373453646665644625515534341111434
411233143325352222232433565357776364354537567464744544677757447355647347634224655221445424234221123
403132433225141544465354452463677637467665487666846666755788647537364356454544666653551223245224340
221322021525352363523636637647346766478588755865687868867645766556546564556653642254324121553211304
403241055444542664465465244335643767468587448558684446585646645783676334334523536424454514335423123
211143511245325363626335376547753746588486548774784555465465555878546563354754643666463543441154014
401300433144233542225644436577656487784787668478478877656566664686876664636644544454356133443543141
331142254354362546353337373665335645767465777854677464757756456544675664356367625622524655111313004
113232441541265332665474663666654767485884568658686557788465466478445735345565533633343655325534312
321022113355332354526456735555544874686468968688698796655997448565647857463454746652554221552251403
122432252412444434645554365777558748764486597677688989696566568546446748747655554456546452215445344
411421324442262525376765477675644878458898595668595797866985998656468566765654543556653226425225120
324235432352442663645466747448576564587577589798759887875957776678887748763645556444663636314323550
344343211553344562466366748877467758889579976698975577669788988788768774877466746334425233322525324
122324422262666463577674356644644786988899585657756686976755588765564885587553633555242365452153531
201351313453255423447473584657654896965976857678687868797668555667667678665663567365445433341542211
433543125456563524745337668677586879576859658667779899879899685766664654775737735747466565261341533
234425124322464357377647455765648697657596898997987887998965588858885666557473667765366453653253114
423421145454426277664757848586849796977989978968787997989889658677897876878555474343764652451533332
025412522653343535565777888646858988889597999796788799787999787977699946465448676557435636335252542
141134456254232633377475678655495758955786766977986989666899977865668764857857566434362336356221553
425122534222652555575536756448895757787888787989687876976997866655765978865477433746664562646142212
031511153254626673663634644788666579996898979668989769678877976996595657666574573435474345226212542
232233144362665635733774464767985596597976688997988789869787899769899788774865464775333646344445431
312145512265246763334446688669576579786887698997789788876769768857897897666647745744466234352315531
125245265445235645546676566658759576979779977989788897777889788697776869574445745473772642652441113
442524136433324757567545875586685577989996768978997898778897787997976785468675547364763256322634413
122114362264363345677747768876966878676997787878877797997687877675865787446565575456336223543411543
135542524335365534573647676446887595978779678987798787977877867895988596684886553453677456444625544
523345155345256676373566557878889799679867889977988898878766697676689999785545856776366325323542354
435121424444367367643567766788555778776869877798997888799897769766999978488777757533536445365522215
123425564543653434336764466465686968666778998998999877879789898695876779777775843467655336225553225
222244562666434557756766787788797597967966797778888989789987687767675968657487533745362622545452122
512353533455336675743756747879576968569886968877787978898778699769777855778644864367374524636355412
332352434424335644376447758478777677796878799977979879778976887678887885446675744337465342332515522
323252314236266467645647474465856866688969976989789878869678688879585795665784853364464336223415322
251455334646623455333344556746578579656688869789888866967976688568799876785648446456543453462134424
135232435366624576744674656655557688787687889677968777886977976785657578545888767656443652242341541
124413534363544257774337877745666676597969678698668667898897667677598656485474536457642652664335354
242352412533366666356438448767498978966788966877879876976778968567899547866867347343763236533115452
231414514653435364756556757566886767869977897986898679776668787986778677845866676564564363432131252
354212534524326436575765744546678857575975789978879867869878965666956755776655473544434254263344514
412334415456362356575755545474856586675688589666689767996659868589655855686466753756444544624531354
233534323333433553747366487768666679979566799866969797665785868996667655465564464755234453441322431
142541242334556243577747464585448545898768785588696876566958768659755856474535747752645464521342113
024341354265635564535745565654787474999866699876996667998578655965475455554643337364256532654422514
342523514523462644264534344468777778555857965885677998786677976975844487563577373444632336314224513
024325342213235664374677336465858446669977596658889875698568768654464784553543775764226245324332350
240325233531254654253746363375785874567879588975659695989786856575465654455743754345434541513335111
131153415425564263663736347735487768444885978899699655558967786868584747375553463224422462455554340
224105535245326664264653465573585645875558756585969699597445574545674767777464743343342245512131210
023322241343425544462546345536374468456467668746584756567867676784865677465345364333444621423523214
042210154211112465654235357647576576765755545857857487884677446576685636776554264454523245143512114
042424212434433423422243335375375475657747844475676845646576666766877337646466556264253234244441233
144422445341111253623426445667736335488676865868585857567856546854737576376345355533445425433303342
402304324414521433525442456755344333775468876844587857478486655444763343735534332553255423442513122
300332425152255255544634244346573437443385544558664688746757476353545445364554346524411134143202201
214042104253144515436425232277433657757567644754857447784557453533347535723524666524545411424333410
033132413521522541465222564466544756756437336336633765737566666353336553224244325645122124121211324
014003114345513541266256564564477367633467443467556573776665343445363732355245442211321112442014333
301123424003353534134444252365233443345764547747747346475444676756667246325234554354213121321233010
312444004305142522441443345246246265353766655343777457653663764554445564446642365532252124202324200
122321243114541443141153664664542624574775636637375334634533475564424253645262423534444321424210133
101342133402113533524313225333345232363353366353535736375656665525226532246265132255444422432043232
202123424410343525344353562442643636233564476734345663676736644233432253265632231154543314433133020
002021404412312523233351342542526464246563652342454633246323454263543662222553544145232222201324321
200323333433022134222542451565366462542256633625664356563422422523456466653425443355143414431302131
111301141124013022552321243335352256226325452522353634546532453444456655454425145215440231201310330
323001023443413423534444534314215424443566445454345346325362634232545135212151541430324040430120112
011302311101402411305252235135343363554362355354445235654463256254345435542232524124432233101001213
322223102103402024201133345541442343125452262443233564234356346515551225111445550404321241212122003
110300120121043342024254432143411131324552665453435466543243231233125233155555410244331412033133100
102212121123001230220431132244433125232421545556434552424254145344532515334444030024021012013312132
010212220130041242431113421111412151151544351553513414213234333151551141333234440022120100013033300
221113213020221104204230431441514222414434525525441433114412353444142113540202000143330101122311021
110110031103212230131323033022115453244443415144332243124522331152241520413243341332301011133031202
011102233213303222404141210033304553434153135332532111424413125424541204413034023314012102311032010
100121131313233020144314131021230331244513135255514312122223121532233404320322331041132102331111002

73
d08/src/a1.rs Normal file
View File

@ -0,0 +1,73 @@
fn tree_visible(y :usize, x :usize, grid :&Vec<Vec<char>>) -> bool {
let mut found_greater_tree = false;
for i in 0..y {
if grid[i][x] >= grid[y][x] {
found_greater_tree = true;
}
}
if !found_greater_tree {
return true;
}
found_greater_tree = false;
for i in (y+1)..grid.len() {
if grid[i][x] >= grid[y][x] {
found_greater_tree = true;
}
}
if !found_greater_tree {
return true;
}
found_greater_tree = false;
for i in 0..x {
if grid[y][i] >= grid[y][x] {
found_greater_tree = true;
}
}
if !found_greater_tree {
return true;
}
found_greater_tree = false;
for i in (x+1)..grid[0].len() {
if grid[y][i] >= grid[y][x] {
found_greater_tree = true;
}
}
if !found_greater_tree {
return true;
}
return false;
}
pub fn run(inp :Vec<String>) {
let cinp = inp.iter().map(|s| s.chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();
let mut visible_trees = 0;
visible_trees += cinp.len() * 2; // Vertical edge
visible_trees += (cinp[0].len() - 2) * 2; // Horizontal edge
for i in 1..(cinp.len()-1) {
for i2 in 1..(cinp[i].len() - 1) {
if tree_visible(i, i2, &cinp) {
visible_trees += 1;
}
}
}
println!("a1: {}", visible_trees);
}

68
d08/src/a2.rs Normal file
View File

@ -0,0 +1,68 @@
fn calc_score(y :usize, x :usize, grid :&Vec<Vec<char>>) -> i32 {
let mut visio_score_left = 0;
let mut visio_score_right = 0;
let mut visio_score_down = 0;
let mut visio_score_up = 0;
for i in (0..y).rev() {
visio_score_left += 1;
if grid[i][x] >= grid[y][x] {
break;
}
}
for i in (y+1)..grid.len() {
visio_score_right += 1;
if grid[i][x] >= grid[y][x] {
break;
}
}
for i in (0..x).rev() {
visio_score_up += 1;
if grid[y][i] >= grid[y][x] {
break;
}
}
for i in (x+1)..grid[0].len() {
visio_score_down += 1;
if grid[y][i] >= grid[y][x] {
break;
}
}
//if y == 2 && x == 1 {
// println!("d:{}, u:{}, l:{}, r:{}", visio_score_down, visio_score_up, visio_score_left, visio_score_right);
//}
return visio_score_down * visio_score_left * visio_score_right * visio_score_up;
}
pub fn run(inp :Vec<String>) {
let cinp = inp.iter().map(|s| s.chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();
let mut max_score = 0;
for i in 0..cinp.len() {
for i2 in 0..cinp[i].len() {
let score = calc_score(i, i2, &cinp);
if score > max_score {
max_score = score;
}
}
}
println!("a2: {}", max_score);
}

41
d08/src/main.rs Normal file
View File

@ -0,0 +1,41 @@
use std::io::BufRead;
mod a1;
mod a2;
fn read_file(path :&str) -> Vec<String> {
let file = std::fs::File::open(path);
return match file {
Ok(handle) => {
let reader = std::io::BufReader::new(handle);
let mut vec : Vec<String> = vec![];
reader.lines().for_each(|elem| {
vec.push(elem.unwrap());
});
vec
}
Err(_) => vec![]
}
}
fn main() {
let inp :Vec<String> = read_file("input.txt");
a1::run(inp.clone());
a2::run(inp);
}

View File

@ -0,0 +1 @@
{"rustc_fingerprint":15594459422025777716,"outputs":{"8204103499295538959":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\tfuec\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\tfuec\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"8623966523033996810":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.65.0 (897e37553 2022-11-02)\nbinary: rustc\ncommit-hash: 897e37553bba8b42751c67658967889d11ecd120\ncommit-date: 2022-11-02\nhost: x86_64-pc-windows-msvc\nrelease: 1.65.0\nLLVM version: 15.0.0\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\n","stderr":""}},"successes":{}}

3
d08/target/CACHEDIR.TAG Normal file
View File

@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/

View File

View File

@ -0,0 +1 @@
a62220af2acc103e

View File

@ -0,0 +1 @@
{"rustc":2347157018072859861,"features":"[]","target":16997346216964277088,"profile":7309141686862299243,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\d05-54bad1502471c435\\dep-bin-d05"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
e737b342d3e62e08

View File

@ -0,0 +1 @@
{"rustc":2347157018072859861,"features":"[]","target":16997346216964277088,"profile":9251013656241001069,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\d05-60235cbe9d69ff8a\\dep-bin-d05"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
f0fa31a79957e157

View File

@ -0,0 +1 @@
{"rustc":2347157018072859861,"features":"[]","target":16997346216964277088,"profile":1021633075455700787,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\d05-cd6375c08847f9de\\dep-test-bin-d05"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

1
d08/target/debug/d05.d Normal file
View File

@ -0,0 +1 @@
C:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\d05.exe: C:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\src\a1.rs C:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\src\a2.rs C:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\src\main.rs

BIN
d08/target/debug/d05.exe Normal file

Binary file not shown.

BIN
d08/target/debug/d05.pdb Normal file

Binary file not shown.

View File

@ -0,0 +1,7 @@
c:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\deps\d05-54bad1502471c435.rmeta: src\main.rs src\a1.rs src\a2.rs
c:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\deps\d05-54bad1502471c435.d: src\main.rs src\a1.rs src\a2.rs
src\main.rs:
src\a1.rs:
src\a2.rs:

View File

@ -0,0 +1,7 @@
c:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\deps\d05-cd6375c08847f9de.rmeta: src\main.rs src\a1.rs src\a2.rs
c:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\deps\d05-cd6375c08847f9de.d: src\main.rs src\a1.rs src\a2.rs
src\main.rs:
src\a1.rs:
src\a2.rs:

View File

@ -0,0 +1,7 @@
C:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\deps\d05.exe: src\main.rs src\a1.rs src\a2.rs
C:\personal\Programmierdaten\rust\advent_of_code\y2022\d08\target\debug\deps\d05.d: src\main.rs src\a1.rs src\a2.rs
src\main.rs:
src\a1.rs:
src\a2.rs:

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More