 All right Welcome to the stream. We're on our new early slot. I have to pack soon for I am going to Spain tomorrow. Hey Lilani. Lilani is also going to Spain tomorrow. I Wonder if he'll be on the same plane Of course we will Because we are sitting together It's gonna be nice. Let's see Yes, she's all packed Whereas I Was at work, so I haven't packed yet, but I'm also more of a lazy programmer I do everything just in time It's just different evaluation strategies, you know Anyway, let's see what day 14 is all about Parabolic reflector dish. Okay It's a large mountain and small mirrors No energy for the lava, okay, there's a lever system ropes and pulleys large metal platform Weight of a rocks you forms a platform In the shape of the platform corals with a drop move and ultimately focus Yeah, okay So in short if you move the rocks you can focus the ditch the platform can control a panel side Let you tilt in one of the four directions The rounder rocks for zero will roll when the problem is tilted. Look you should also base The position of the only anti-spacing rocks was my input Okay, let's just paste that right away. Let's get started with a party. I think I'm trying to go a bit fast today Well, that's good with all of y'all Let me see I wonder if I can do file example How's everyone doing today? How is Lil Lanny doing today? my biggest fan No response Or maybe she's typing a long message. We don't know Chat doesn't have typing message Let's say These are three kinds of things. I think we did that indeed. Well Do do do do do do do let's just copy paste This Doing good. It's good Doing good. Maybe you're doing well, okay Let's see. This is a No, all right. Let me just see what it's supposed to be. It's supposed to be a rock Round rock Round, okay see round To entry dot hash oh Round and it's just a list of list of entries. This is map ours row That's actually just to map map to entry where Let's now Main is equal to do read file Example into Day 14 GTO Day 14.HS The day 14.HS. Oh day 14, and it did work. It seems Mm-hmm. I didn't do lines. I didn't even parse it and say Let's just name is Mars actually. Okay, we got the lines Okay, you're not the position of all the other spaces and rocks. Okay start by tail-thing the level or lever So all the rocks will slide north as far as they will go Let's get the possible input Well, it's kind of big say say You notice that the support beams along the north side of the platform are damaged total load The number of rows from the rock to the south of the pitch of the platform including the row the rock is on Okay So let's do a count load entry to load into it Count load equals map Where num rocks is equal to length thought filter Is equal to map rocks entries and then We are going to sip Length entries to one sip with And then we're gonna do and right times and And then we do some let me just see now, okay Of course, this is not We haven't done the tilting yet, but we are gonna just see how it works Map and print parse a print.com I think this is your problem. Let me see G8 CI 10 to 170, okay 10 9 This one works. So we just need to do length entries length and then lengths Entries minus one and this one will work. I think Askal is clever like that. Not bad, huh? Okay, so we count the load now we want to write the tilt function and What I'm gonna guess is that we tilt and then we tilt another direction But we actually only need to we only need to tilt in One direction at once I think What I'm gonna do is I'm gonna always tilt down and then just have this be like this Okay So we will actually we'll just reverse it Okay Okay, and the numbers is same because I reversed and I also reversed it. What so let's see Tilt Takes in the list of list of entries And returns the list of entries, okay Now tilt of the empty list Actually, so we're gonna tilt x y axis That's gonna be something But the tilt of anything else is just gonna be exit. So if we tilt one nothing happens if we tilt two And nothing happens So let's see where so we are going to Okay, so this will tilt one step at a time Let's see Tilt one x comma y x comma y Is equal to okay Okay, so let's just write it like this So if as I access the one that's above So if There's nothing there Then it's just gonna be okay if it's tilt Same with this It's gonna be Let me see here Okay Sorry to tilt of this is gonna be like that Tilt of hashtag It's gonna be a hashtag. So it's actually Let's just say that the tilt of x y is gonna be That's just the default case and default case is nothing happens now tilt one of Okay, we have the round thing now if we have a Hash then the Then it's just gonna be oh and hash They were not gonna do anything as well Tilt one. Okay, so it's really that's also this case But tilt one of dot Of oh and dot this is not gonna be Sorry, it's actually round and dot then hash Okay, round and dot and then the new x is Going to be No, if it's so x and y it's dot around around and out that a new x is gonna be dot and the new y is gonna be round Okay Now if it's a tilt one Okay, so it's just gonna be like this. Now, let's see So x prime y prime Is equal to unsip Uncurry tilt one Sip X Y So this will tilt one step and then we are gonna say tilt This is gonna be x prime And then tilt one y prime axis No tilt My prime axis Okay, I think this will work. Now, let's see Okay, and now we're working with this example Let's just print it again And then we print Tilt, okay, let's see put sterling Mm-hmm Okay, we seem to have gone Where it went quite far actually. Okay, so let me see here There's a function called so we just take the fix point of this This is gonna be bad, but okay fix Okay, this one doesn't we can't just call fix directly. So we just need to kind of manually do it big X prime it's gonna take in CQ a a and then function from a to a And then a and it's gonna return an a fix point fix point a F a is equal to if a case F So we need to be careful here glad a prime is equal to F a if in if a prime is equal to a a prime else fix point f a prime Mm-hmm So I'm just a fixed point tilt and let's say Where's that and is this the same? So round round round that's hash round Yes, round round dot dot Yes, and then round round dot dot round Okay, it seems to have worked and Count load And then count print of course, let's see 136 yes, that's exactly what we wanted for the example. Now, let's see This works on the input Part one is equal to Count load over fix point tilt Over reverse of bars of lines No, let's remove the lines We're gonna get a list of strings here Part one Okay Seems a reasonable Okay part one done Doing good so far. Let's see what we have to do. I'm supposed we have to You need to move the rocks to the edges of this platform importantly, but now it's been labeled spin Each cycle tilts apart from four times of the round rock for all north and west and south and east Okay, I'm gonna guess there's gonna be some loop there Well, that's it. If there's a loop we just memoize Let me see So this was to go Okay, so Part two is equal to okay, so We're gonna be Stairs we're gonna see where ease is equal to Reverse top ours Stairs, okay, so to go so we go north So that's actually so we're gonna go let's see so we want one cycle. So, okay, we do Fix point tilt Yes, okay, this is one and then we want it to go To roll west so to roll west And let me see You just see what this is Map them, okay, now I'm going to we're going to transpose and we are going to What is the problem here now have I fixed my tilt works, okay Transpose is not defined. Okay import data list So I transposed it Let's see So everything and then we transposed it and now so everything went North and then so if north is down then the west is too So we will reverse it Let's see. So This hash here It should be We just reverse it again. Okay reverse We just got to get the directions correct. Okay It always goes down I need these lines, okay, so it starts like this and now Okay, then we transposed it so now they're all So now Yeah, now west has become down, right? Okay So we fixed point tilt, okay, this is this is north then we do Let's post three verse And a fixed point tilt Mm-hmm Okay, so we let's do here reverse parts No, we don't want Okay, so one let's do a rod is equal to it's gonna be a Cycle and then we're just gonna say here. So we do a north and then we do This is west and And Then south then we transpose and reverse again and Then we do East Let's just see and what it happens to be after one cycle Print part two Dot lines Okay, when I the map is The map is not correct I think we needed one more for the map transpose thought reverse north west East And then maybe one reverse No, okay, so it's correct now because we'd always do it We get to go down, but we just need to reverse again here. Okay. Now the map looks the same But the cycles are wrong We're getting there slowly, but surely let's see after one cycle Maybe I need to do part one first also. I mean so they all slid to the west, right? They all sleep to the West, but they should have slid to the east. Let me see Mm-hmm. Mm-hmm. I do it once. They should all slide north Okay, and they all slid north Now I want all of them to slide west. I just want this one to go here, right? transpose dot reverse West is down, right? Let's remove these other ones here So we have this one Okay, so they all slid up And now I want west to be up. I want west to be down. Let me see So west is the one, yeah, okay, so the west is down, right? So these hashtag hashtag are here. So it's down now And then I want to slide all of them down. They do not all slid. They all slid up Mm-hmm. I think I might be messing this up a bit too much and Let's just make the let's just parse the strings, okay Let's not even do anything Mm-hmm, and I'm also reversing here God damn it. Okay, this one is correct And now if I do fixed point tilt here, everything slides down Right Yeah, everything slid down. Okay, so we have to do Dot reverse I fixed my tilt Okay And then we just reverse again To get That everything slid up, okay north Now we want to do What are you gonna do? Transpose Transpose dot, okay, and then let's see fixed point tilt Tilt dot tilt And now everything slid East right Okay, so we do Reverse here And then we transpose and tilt and then we reverse again, and then everything slid East That's because we're reversing twice So if we just don't reverse Everything should slide east, right? Now west. I'm gonna need to reverse again at the end Get confused with all these reverses and transposes reverse dot fixed point. Okay Okay, so I transpose and then after that I take the reverse and remove anything down and then reverse And then transpose Okay, then everything is slid West Okay Now I want everything to slide south. So I just do West then I just do fixed point tilt and then everything slid south And then I do east we had to just do Transpose dot fixed point tilt Tilt dot transpose Okay, and this one should be the same as on the one here Okay So that's one cycle and then we want to say who go HRH and then we're gonna do map and map and map and print on Take four We say L Into Sure, and then He's gonna take four and see what four cycles look like. Okay, so like that's a that's one cycle outside zero cycles and then Mm-hmm. I got this after zero The one cycle two cycles is correct Zero cycles one cycle is correct Zero one cycle. This is two cycles Got a hitch in the music there. Let me see. Okay, so that's correct for the So So, let me just say we cannot do this crazy thing Let's you see so this is after a billion cycles. Yeah, how big is this number given? This is a lot of cycles Cycles is an integer. Let's see and let's see if there's a loop So we're just gonna check for the find the loop it's probably gonna be a loop go And we're gonna have set dot scene set that empty Let's import data dot set Qualified Set and let's just say and go Go scene and Yes is equal to now if Yes Set dot member Scene then and Else go scene so Yes Might be off by one here something like that set touch and search Seen Cycle Probably needs to be like this scene. Oh my god And okay, and we're gonna bang this we're gonna bang that And we're gonna say one here We're gonna need bang patterns or this Gdc 2021 For qualified data that set as a set and I think I just Screwed up the order here set dot member go takes in a set set dot set of Entry and integer and list a list of entries and returns an integer Yes Okay. Yep It was like that Now let's say find the loop Let me see. So we start at Go Set that empty zero. Yes. Let's see Probably gonna be some loop Can't believe it's not a loop. It loops after 10 Wow, not bad. Okay, and Let's just confirm that by saying Interate Cycle yes, we'll say that this is Yes, this is just gonna be Take 20 Couldn't match type. Okay, but the loop might not be the The loop might not of course not be the Like it's not it's gonna loop after a bit but not it might not be the one Let's make this map to int now if This case a map Yes seen map yes Just and prime Go map dot in search Seen Plus one Cycle yes Then map Report the strict map Okay, what doesn't it like here? And I need to provide the value here So map dot in search Yes And go and map dot empty Zero yes Okay, so three it loops You know, what's the length of the loop? So number 10 is the same as number three Loop so LS L People go map dot empty zero yes Now we're gonna say it's is equal to iterate Cycle yes And I'm gonna say LS so let's see It's LS Is equal to it's Lr is that correct? So the the one at number three is equal to the num 1 and number 10 and It's LS is equal to it's Lr plus Lr Lr minus LS so Okay, so LS Lr Lr plus Lr minus LS so every So every after the third Every seventh is the same Okay, and So now we can just do Sykes can Sykes be Can Sykes be an integer? Let's see now. Let's see what is Sykes minus three modulo Lr minus LS I Think we need to do From integral here. What is this Sykes? No, okay, I think maybe it's okay Let's first say a Sykes minus three Yes, we're not getting like some overflow ever. Okay, Sykes minus three is So module three so it's the third one So let's Say here It's bang three plus Countload 134 Really? Okay, I think it's gonna be this So we start at three and then it's module o three So I think it's like this Let's just say 134 oh It's too low Wait This was running on the example Which makes sense because it was quite fast, let's see Okay part two, yeah, I also thought it was a very low And this is should be it's so this is LS Let's let's write this a bit better. Let's say LS LR I just want to make sure that we are getting the crude thing Okay, we fell input part one I'm gonna refile and put into part two wait Example we should probably we probably get it for the example, right? And the above example after one billion cycles a total in the north support beam is 64 but we also had to Reverse let's make it work for the example first We forgot to reverse Count load because it's it's counting the one on the yeah, okay on the It counts the load on the south beam because you were trying to be too clever, so here it says 64, right? Now let's do it Input Okay, it seems like the cycle is a lot longer Okay 160 let's just See if we're correct. No That's not the right answer answer is too low Ah This needs to be Sykes minus LS. Sorry. I Was still using three there. No, I'm just going to bail out But look we I think we did it in Actually in 19 seconds, but We didn't have to simulate so much of the thing Let me see Okay, this one might work. All right J-14 done quite a nicely There's some modular arithmetic. We kind of figured out that it was gonna be a loop It was nice. We could have also Ran it like a trillion times, right with a Memo is in the cycles function and just say okay, but this is a lot easier, right? So after you've gone 81 Then it loops every hundred and sixteenth time. So then we just It also the trick was also to get as we go from to the start of the loop and then we count how many times After that like it looks like so where in the loop we are in the end and then just works out All right, we did part one and two in one hour 15 minutes We're gonna let that slide today We are gonna do a very early stream tomorrow like a morning stream, but I Think it's part one still Correct Just before I don't want to commit anything. That's incorrect. Hey one zero eight, then yeah, it's correct Okay Okay, so yeah, we're gonna do a early stream tomorrow At maybe nine in the morning because I'm leaving in the afternoon I'll be gone So I'll be gone Saturday, but I'll be back on Sunday, and I'm gonna hope to stream again on Sunday So we'll and then we'll be one day behind we don't catch up soon Hopefully if I manage to finish tomorrow Early, but I'm gonna give it like an hour or two tomorrow. We'll see but okay. Thanks for Tuning in I see you tomorrow on a different time That's it all right. Bye. Bye