Advent of Code 2021 - Day 19 - Update

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello explorers it's monday morning and we have a result and i built on a great a thing that i found out from one of you and so jonathan de gea was suggesting that going through all possible position was also my initial thought but we don't need to check them all we only need to check transitions x y f in your code f x f x f y and f send in your code that are guaranteed to map to at least one beacon hope this is clear enough without uh giving you the full answer so thank you jonathan and it i guess it was so i got a result here 308 let's see if that is the correct value put it in and yeah you get a gold star i get a gold story everybody gets a gold star so let's see what part two entails sometimes it's a good idea to appreciate just how big the ocean is this is using the manhattan distance so far a part of the scanners how far apart do the scanners get in the above example scanners 2 3 and are the largest manhattan a distance apart in total they are 1 97 [Music] uh 1 uh 75 249 units apart what is the largest distance between the any two scanners okay and uh good part here is that i i got actually a hint again from another one of you which was matthias kern and let's state that two scanners a and b attack the same 12 beacons and the distance between those two and again the uh manhattan distances are the same regardless when you look at it from scanner a or scanner b direction rotation does not change the distance that gives you a way to pair beacons a from a to b to b can be from b their sets and distances or other beacons our respective scanners have a large intersect and i'm sorry but i didn't understand that and i didn't get the manhattan distance and it was sold for long ago that i actually looked into the manhattan distance but i was lucky enough that i have written out each of these beacon answers here so i will create a new file with all the beacon answers and just read them in again so i don't have to run this and then calculate the distance between them that's my way of doing this so i will eat some breakfast look into that and count some manhattan distance so see you later and i'm back and i have eaten breakfast so let's see here and i calculated manhattan distance to 12 247. so let's put that in and see if that's correct no it's too high if you're stuck make sure you're using the full input data also general tips about page yeah so why was that incorrect um because i got the first point correct so i was pretty sure that i should get the second point correct as well so let's go in here and see this was the input data that i had for that and here i have the input data for this um and i've added the zero and i have all 24 beacons um i wonder if that helps should probably not do but we have 25 scanners and if i look here in the main result we have scanner up to 24. hmm [Music] so let's see one zero one two three four five six seven 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 hmm and i've sorted them i've gone through all of them and checked for the largest distance so i did a really sloppy job of checking for the distance i just took scanner one scanner two and then got the distance between all of them if there is the same one it doesn't really matter because that will be zero so but we can of course if s1 is equal equals s2 continue and i don't think that will help yeah so we get the same result here we just check a few less hmm so that's interesting yeah i will go through and show you what i did day 19 day one and if you have any suggestion on what to do in this part b then just tell me in the comment section so part a first off we i went through all the things about scanners and beacons in the other video so if you want to see how i actually checked which beacons have which 12 beacons they have in common i have a video that was the first thing i did and i got stuck that it was too many positions to check out but after jonathan's um little suggestion here i figured out that what i needed to do is actually get all possible positions and possible positions and was getting these test beacons so i got all the beacons from b1 uh to b2 and what i did here is that i just took one of the sets of beacon here because if i took all of them as i did down here then i got too many so here i have a prepare and i just get a list of all the beacons that is [Music] in comparison to this specific um beacon which means that i will check all the possible values a scanner could have and and then i return that um as a list here and when i have that in my find scanner position all possible then i will go through that list and use that as my input to this get test beacon and that will push it right through to this get test beacon as i did before so i got all those beakers that i could test and then i used to go through them exactly the same as i did earlier the only difference is when i change the position here i not only take the position of this uh specific beacon that i found um let's see number [Music] number overlap because uh yeah possible position and i get xyz of this beacon with possible position changed is to that and i also send in this test beacon i so i get all the beacons and i the only thing i do with this test beacon is go through the hash list and add those to this set of beacons here so that's what i'm doing here um and then i got all the correct positions of my different scanners so i found an id with a specific position and if we look at my result here in the run of this i also type out how long time i take for each run and you see here that each run takes about 35 or yeah less than 40 seconds per run if i don't find anything and if i do find a beacon it takes 3 4 seconds so it takes significantly less because i will break and return if i find the beacon and i type out which id the specific scanner had and the beacon or scanner value that is the value was interesting here so i didn't change it up to be the actual scanner that i returned that could have been a little bit nicer perhaps but that's this is what i did um so i have all those values and then in order to calculate the manhattan distance i created new tests files for b here um let's go down here and i copied all the rows into this line and also all the rows into this one and then i went through and read all of those in create a new scanner with that specific line and these scanners the only thing it does uh yeah the idea is not the most important thing but um i read the x matcher got the x value and parse that into x so this pattern here the pretty much the only thing i say here that i want uh this as group one so group one would be all everything in between these parentheses so i can get group one here pauses as an integer and put it into x y and z so it's just a way of easily with regular expression parse out each part here so i don't have to do any extra to get actual values um and then i get all the scanners read in so if we go back to day b here and look here i should have a list that is all the 25 scanners with the right values so all the scanners are read correctly so if i don't have the wrong places for the scanners then this manhattan distance thingy should be correct famous last words um but it was too large and i have used the long which was a bit of an overkill so it's not something to do with the variable either that i'm pretty sure of so i'm not really sure what i'm doing wrong here probably the first part is wrong in some way but if you know or have any suggestions leave them in the comment section down below if you like this video give it a like share it with your friends and colleagues if you didn't like at all give it a dislike if you have any other comments or suggestions leave them in the comment section down below if you haven't subscribed yet please do that and i really hope to see you in the next video [Music] [Music] [Music] you
Info
Channel: Daniel Persson
Views: 54
Rating: undefined out of 5
Keywords: advent of code, advent of code 2021, advent of code in java, java jdk 17, challenge, कोड का आगमन, कोड 2021 का आगमन, Aufkommen des Codes, advento do código
Id: lPnTBEhFfkM
Channel Id: undefined
Length: 14min 23sec (863 seconds)
Published: Sun Dec 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.