 Hey, hey, welcome to today's stream We're gonna do a long one today We're gonna try and oh wait, it's my microphone like super loud now Huh maybe I Like this yeah, this should be better, right? Sorry about that So we're gonna do a long stream today We are going to do Day 14 the advent of code If we finish it early enough, we're gonna try to do day 11. We're gonna catch up So yeah, welcome to today's stream Now let's get started. I also want to say well, I'm gonna wait a bit. I Have a special birthday wish that was supposed to come yesterday, but It didn't come And then so yeah, we're gonna do both of them and Then we are going to take a short break like between the two Just so you know, I have to catch a breather and stuff like that, you know Gotta take care of yourself. Let me see Like this. Now we have optimal terminal size Am I wrong? All right, let's look at day 14 Also, let me know in chat If there's any audio issues if there's It's anything really I'm always trying to improve but It's hard to it's hard to tell, you know, because I'm I don't watch the stream. I just do the stream so Y'all have today also today Especially we're using a new encoder. We're using the Intel quick sync encoding, which is like a it has like a specialized chip on the CPU to do video encoding For some reason, I mean, yeah, okay, that's good So let me know if the quality is bad or not It should be good. I mean, that's what the online kind of reviews said But I don't know. I'm not watching the stream All right, let's get started with today's stream. Let's open up So open up the new one You're joining us from earlier You notice that my setup is a bit different and that's because I am streaming from Iceland now. I'm in quarantine in Iceland. My first test came back negative. So I didn't catch it in Sweden But I might have caught it on the way So we got to be careful We want to hug my grandma's right For Christmas I had like a super get up That was It was intense. I had like a face shield and everything. That was nice. All right, let's say let's see module main where Let's uh, let's uh, let's look at today's problem And with a code 20 20, so how's everyone doing is everyone is anyone done this yet? Does anyone know if it's hard or like what's what's the dealio? So good stuff day 14 Okay, now we're gonna do some stuff we're gonna be editing a memory That's gonna take some statement and belation. Let's see the asher ferry approaches the seaport the captain asks for your help Again the computer system runs this port isn't compatible with the docking program on the ferry So the docking let me just lower The output of my desktop volume a bit What if I do like this? Yeah, you can still hear it, but it's a lower for me All right now I Mean I used to have like a better sound card. I can like tweak how much I hear myself like a monitoring and I could tweak I Could tweak how much I heard the Audio coming out from my desktop, but no I can't so But you know, I think this is quite a nice setup for being on the go, right? It's quite expensive too, but Life is not about money. It's about enjoying So if you got to spend money to enjoy That's all right by me. All right, so let's see After a brief inspection you discover the seaport computer systems are used a strange bit mask system in its initialization program. I'll do you can Although you don't have the correct g-code ship handy. You can emulate it in software. Okay? Initialization program your partial input can either update the bit mask or write a value to memory Okay Values memories are just a both 36 bit unsigned integers That's big integers good thing we have That's cool integers Okay, bit mask is always given as a string of 36 bits written with the most significant bit Representing two out of thirty two two in the power of thirty five and left the least significant bit That is the LS bit on the right. Let me just check check one thing Did I Yeah, okay, and One more thing just the one more thing All right, it's it's okay. So we take a bit mask. We're gonna use data that bit for this I think the current bit mask is applied the values immediately before they are written to memory a zero or one All right to carpentry bit in the while you well an x leaves a bit in the value unchanged For example consider the following program mask is a bunch of x's one and then xx zero x Memory eight is eleven is one one. Okay, mem of seven is one or one and then mem of eight is zero So the masks the mask it specifies all right two bits in every written value the twos bit is overwritten with zero and the 64 s 64 s bit is 60 okay a bit representing 64. I get it. Okay. I get it The program then tends to write the value 11 to memory address eight By expanding everything out to individual bits the mask applied is as follows so value 11 so that's Decimal 11. Yeah, okay one zero one one Okay, well, so it's a decimal one one there not one oh one. Okay As applied as the value so value is zero one one. Okay, and then it plays a mask and then it changes This bit here to be zero and this bit to be one. Okay Yes, okay memory address eight and then the program rise to write one oh one as 101 to address seven this becomes one this becomes okay and Like this and then it does This time the mask has no effect. Okay. Yeah Finally the program tries to write sprayed right zero to address eight The value is zero and then it masks it and then it's 64 Okay. Yeah 64 is written to address eight instead overriding the value that was there previously To initialize your ferries doggy program you need to sum of all values left in memory after initialization program completes The entire 36 bit address base begins initialized to the value zero at every address In the above example only two values memory are not zero one oh one one hundred one Add address seven and sixty four I treat us eight Producing a sum of one sixty five. Okay Seems seems good now, let's take in the program and Let's get started you file test dash input Okay, now, let's write the parser like we did yesterday probably overkill. Let's say, let's Have a copy of the input here Okay, and we are going to import Texted on parsec, we're gonna import text up parsec It's gonna be like this Parsec is gonna be like this main so So how we're gonna represent the program we're gonna say Data memory the data data Memory Equals okay, so that mask so they men okay their mask It's going to be a Function from bit to bit right import Qualified data dot bit No, just use import data dot bit, right? So we're gonna be using mem integers here to represent these values So this is just gonna be integer To integer that's a function, right? Okay, and then the memory is going to be an array with Integer Indicates because We have too many bits to carry around an int Memory is gonna go from integers to integers Okay, what doesn't want to fit it up bit what? Dated up bits like this Now get input file path to I Oh memory Get input equals so pars Pars right we have to import Text on parsec by string What nice that this is overwritten. Oh Right. We have to import data dot array like this okay, and Hey, how's everyone doing tonight? Oh, hey to me Yeah, happy birthday yesterday to me well-deserved birthday Parse file No, wait What was the text of parsec one text parsec? It's quiet today. It's not not as many people as usual. I think it's because it's a Monday People don't like Mondays parse from file Pars mem This is gonna be pars from file parse mem IO So this is gonna be Loures FP FP and then case res Can't we just like use something from data dot either to do this Yeah, yeah, I know that's why we need state so we're gonna be using the SD monad Oh Set the mask multiple times Okay, I See so every instruction We'll set it multiple times, okay, I think that's maybe spoiler alert for part two right Timmy So parse men is going to be a parser for a memory Right the actual input will set the mask multiple times Okay, so So, okay, so I see so we will need to do it that way After brief, okay, so initialization can either update them bet mask or yeah, okay, so okay, so we have a we have an instruction here So we let's see data instruction It's going to be it's either a mask update Take care or It's going to be a memory mem op and we're gonna have the Index of the mem op and We're going to have the value of The mem op let's deriving show So this is going to be a list of Instructions Okay, so pars So parse a ince That's just going to be a set by new line of Text.parsec, yeah, I would use our ad oparsec here But It's not installed by default on my system So I'm trying to use like things that are used are there by default essentially Let's see The boom That it's gonna be set by one Right and I was here parse ince and then a New line right parse in a parse in And then so parse ince is going to be a parse ince parser for Okay, so we parse in and when a parse in That it's going to be okay, so it's gonna be a choice of Parse a Mask or parse Parse mem op Parse mask So what is parse mask gonna be? Parse mask is going to be It's gonna be I think you let's just do so it's gonna be do so it's gonna be string so that starts with a Mask Mask space equals space Okay, and then We will have a parser Yeah, I mean I'm not gonna download the input right away So, let's see, but I believe you I believe you Timmy so how do I define a mask? Did it out of bits bitwise Or so so we're just gonna parse them So they're gonna be x or 1 or 0 so we're gonna be we're gonna have a like a list of nothing's Or it's gonna be maybe and then just 1 or just 0 I think no or just nothing just true or just false Okay, so we're gonna do many one One Res is many one of parse mask Mask a info something like that. So parse mask info. So then we're gonna like return a mask info So now let's just do here mask info to mask over this Now parse mask info it's gonna parse It's gonna parse maybe Gonna be a parser for maybe bull parse mask info it's gonna be It's going to be what it's gonna be it's gonna be So choice of okay, it's gonna be char X And then we learned yet last time like it's this operator, right? What was it? It was that operator, right? Yeah Then we do nothing and then this Let's see. Okay, and then we will say Nothing Char X Or just true Char one or just false Char zero Okay, and now we have to define Mask info To mask it's gonna take a maybe bull and it's going to return An instruction so and we're gonna define a mask Okay, it's from integer to integer Okay, so we're going to say here mask info to mask. Oh No, this is like per instruction, right? No, no, yeah, yeah, so we will take in a masking photo mask. It's gonna take a list of maybe bulls To instruction, right? So we are going to say sip. So it's going to take you know, zero and So on And we're gonna look at the reverse Misc so reverse of the mask, okay, and we are going to say So Where okay, so now so we're gonna and then we're gonna apply this f function here We're gonna apply. What's the type of uncurry again? music T uncurry right We're gonna apply a map uncurry f to this We're uncurry F No, this is we're not gonna define uncurry. We're gonna say so f of I comma so f of I come on nothing That's going to be That's going to be a id I Want to see so cuz like now I'm like defining a function will just like apply all the functions in a mask to the integer, but that seems That seems a bit much, right? Okay, let's just do this way This so if it's nothing And it's gonna be it's gonna be a Function so we're gonna be getting a list of functions, right? This is just gonna be okay, we're so we're gonna first before we do this we're just gonna say filter wait, let me see So we have these what I'm gonna do first as I am going to I Want to like I wouldn't like I wouldn't like to cat maybes and then just let me see I Sip with the numbers cat maybe of So we're gonna say here Drop nothing is going to be so I comma nothing is going to be nothing Drop nothing of I comma just X is going to be just I comma X So then we're going to sip this and then we're going to When a cat may be a map drop nothing of these And then we're going to Map okay, let's let's just look at yeah, so this is gonna be giving us Like the list of instructions and then we will say Now and then we will have like a list of you know One is gonna be crew To who's gonna be to is gonna be false or like Five is gonna be false So so then we want to say so to fun to fun is going to be to fun I comma True to okay, so to fun I comma B is gonna be if B then Set bit we're gonna flip set bit I else flip Let's see here. We're gonna we're gonna See it's gonna flip Flip and then if be then set bit Else clear a bit So then we change the model to functions and Then we are going to say Map to fun of this and then we're going to we're gonna say fold L one Okay, now fold L and we're gonna fold L with compose on id Of this list You get what I am doing here. It's kind of crazy, right? Anyway, this is how I'm going to do it. This is gonna be very inefficient But we're not using the bit operations. We're like we're using data dot bit And I don't think that it does any optimization of it But that's that's how we're gonna do it. I'm just wondering cuz like it doesn't say any oh here ask oh, this is gonna be Mask, okay It's not we wasn't returning any errors or anything Let me say parser on input like this Okay, and issue here Couldn't match expected typing instruction Yeah, so this is gonna be mask Of cat and there's gonna be cat maybes We're gonna report that from data dot maybe okay, and oh Wait, no, yeah, wait, we can just do map. Maybe maybe Which is gonna be fine. You can map maybes here Okay masking photo mask MSK Let's not derive show. Let's actually say Instance show instruction where cuz we can't derive it show mask MSK is equal to Show mask applied to zero bits Show Mem pop I a n equals This is gonna be Mask mask equals plus plus It's gonna be mem Let's plus plus I show I plus plus this equals plus plus and Show and right Okay, so this is gonna be pars in's a parse in's Okay, now we parsed masks and we did this funky integer thing That's parse memory operations parse mem up That's gonna be easier right parser Instruction parsing mem up That's gonna be do and then it's gonna say man And so it's gonna be string man, and then it's gonna be Take while take take It's like n by one or something like right right and by Separated and ended by step. Okay. Why is it? I want to I want to take like a I Want to take many many till Okay many till right Then we're gonna say Adder it's gonna be many till applies parser P Get many till and then something here, and it's gonna be Char like this dude returns the list of values returned by P What is try mean try I mean it's okay. So you want no, okay? Do we want to say try this? And here we want to say many till digit right and then we want to say We're gonna you know just gonna read This and then so that's gonna be our address and then it's going to say string I Think it's gonna say like this Like I think it will have consumed the char and then string and then Well, it's gonna be the same again. That's gonna be read many till line Many till digit line and then we're going to return a Mem Up I drew a well doesn't parsec have a handy decimal parser That might be that's actually good idea Yeah, well no it parses digit parsec decimal so this is like Not included in parsec, right? So we'll just we'll just read it. It's gonna be fine Okay, now let's try and see what happens Main it's gonna be Print main equals do get input test input into Into print Well, we haven't defined get input What's wrong here? Oh, yeah, okay? We're gonna get a parser for sure, right? Or they would just nail it All right, we have to run it. Okay. We got mask 64 Well, we didn't get We didn't get anything else probably because This one fail So you have we are showing it here. Oh So I okay, so I think it's just I Think it's just gonna be not new line. I think it's gonna be just Many one digit. I think because we do it's it's a pie on the lines, right? We do this and then not this Okay So so we did a choice To say parse mask a string mask equals. Okay. Mask info to mask mask many one parse mask info Yeah, we don't need the eye here So this is gonna be what man eight. Yeah space equal space Parts like has some Some kind of thing, right? Can I just write a To make it print out what is happening? Let's see what happens if I say here There we get mask and then what's left? Oh, okay. Oh right It's because this is windows So it's not actually new line it's gonna be end of line Dammit, okay. See the white part is like is nice. Are you out of town? Yeah, I'm in Iceland. I'll be here for Christmas I'm currently just quarantine Which is I mean, that's fine Unexpected e Expecting mask Today exit Okay, now so now it wrote mask. Oh, it's still still doing that, right? It's still Still like showing me that the entire state here. Is that just because they will always show the entire state Unexpected e expecting mask put try in front of personal what? Really, it's like in in text read and in text dot And in text dot And in adult parsec like I use adult parsec and then I didn't have to I could just say choice That's lame. Yeah, but okay. Yeah, make sense. So it had already kind of tried to consume mask. That's weird things eat up Eat up who's over You know hacker nicknames or like online nicknames They weren't really designed to be Pronounced, you know, they're designed to be looked at So they always become a bit weird All right, I'll stop this trace here. We don't need it anymore Okay, now we have a list of instructions It's Alex. Hey Alex Yeah, exactly. So my name like treat low It's always so we when people are treat treat low. I'm like You know, it's not supposed to be said Okay. Now then we have the memory Data memory That's gonna be man. And this is gonna be like the current memory Okay, so we're always gonna apply the current cute name It's supposed to sound harsh, you know, supposed to be like, oh shit treat low is here. He's gonna Take over our systems Why use array and not map? And I think it works both ways Because I don't think the array array is just kind of optimized for innumerable I think it will be faster, but I don't know. It's just because it's an array, right? It's it's a memory and we're gonna be addressing locations in memory That's why I want to use Memory here So, let's see run in Corruption Instruction to memory And so we are going to say it's actually gonna take memory and then Instruction and then a memory Okay, run instruction mask F is going to be and then the end And is going to be and You call it mask right we just call it mask see yeah, we call it mask and mem let's Move this below So there's gonna be and and then it's just gonna be mask Equals F Well, thanks for the follow Sicilian salad wouldn't mind some Italian salad right now Like, you know the Italians They know how to make salad they just put like a bunch of like fetish not fetish Anyway, the salad I imagine it's like you have the bills balsamico Balsamico is so good You can hear it. I've been in Iceland for a couple of days now and my Icelandic accent is already coming out That's just how it is. Okay run instruction mem up Okay, we're gonna take the memory And we're gonna say mask equals mask and we're gonna say mem Adder Val equals First of all, we're gonna apply the mask to Val and Then we are going to update array Alright, also also to me. So we might try to do it more optimally later That's actually let's actually just do this right now Let's say here Instead of instead of saying a this Let's say here that we're gonna say run program It's gonna take in a list of instructions And it's gonna be an ST data dot ST data rate ST monad asco Monad ST control monad ST Because I think it's gonna be super slow if you don't have that import control dot monad a dot ST import a Data dot array dot ST array data dot array dot ST So we're gonna have here run program instruction. How do we write this again? This so this is gonna be the state the s is gonna be the state and then the a is a return So it's gonna be this is gonna be a the mask Here to integer and it's gonna be our ST array Integers to integers, that's right. So That's not how I use ST right Okay, so we actually want to do this run ST array That's the thing well when you want to do So is it gonna be I? Can never remember this So run programs a run program is just gonna take in a list of instructions and It's going to return an array of integer integer We don't care about the final mask right program a Instress equals do so now we're gonna say Where run program prime equals run ST array We'll go let's see ST you array Can integers be unboxed? Probably I mean, yeah, that's what I'm thinking right So let's see run ST you array unboxed array should be an instance of X in 64 Yeah, okay, so let's do that Run ST you array, so let's have these not be data dot integer. Let's have them be dated into 64 in 64 and Then these are gonna be x64 or 64 to in 64 And you find We need to import in touch in 64 from somewhere We're not using the same word Whereas in 64 defined it's defined in data.int Import data.int Okay, so we now we have 64 to 64's Like the cool thing about that is the way we do the the mask info thing is that it's using data.bit So that's gonna be That's gonna be okay But it's gonna still gonna work So run ST you array dollar do So So that it always starts with an initial mask, right? Bitmask has always written in with the most Bitmask all union unless the current bitmask is applied to values The program starts this program starts Okay, so what is the default mask? Let's see. Okay, either update. Let's just get the input Okay, yeah, it always starts with a mask Stay 13 Okay, okay, so it's so this is gonna be run ST you array and this is just gonna be something that It's going to return us a run ST you array It's going to return as a you array Then we need data array unboxed. Okay, so run ST you array so We want we want to write like a loop Okay, so It's gonna be for all s STS So we're gonna write gonna like write a loop somehow wait, so that's like this is gonna be initialized. So so It's gonna be this is gonna start with mask. Okay, and that's gonna be mask F so the we're gonna say a MSK it's gonna be new ST ref Google you ST ref That's in data dot ST ref Import data dot ST ref new ST ref MSK MS and it's complaining. So okay, it's gonna be this and Then okay, let me see They play to create and work with unboxed mutable array before returning on a mutable array for a reversal This function always copying the rate before returning it it uses unsafe array freeze internally But this rather it's a safe interface to that function Okay, so let's see that so we want to create like a new ST array somehow So now we need M array, right? Yeah, okay Import data dot array dot M array Not that safe Okay, and then ah, so man, it's going to be The new array. I don't think creating a new array with the bound zero to max bound of int 64 Is a good idea. I Think I think Tim is Idea of using a map is better because yeah, because it's gonna be super sparse So, let's let's do that instead Let's all let's just write it like this. I think I think it's gonna be fine. I think it's gonna be fine actually map int 64 to int 60 64 no M arrays for us import Okay, so Let's see. We're gonna say So this memory here. Okay, so the M and the mask with the mask is equal to mask and Mem equals to mem so then we're gonna say What is it complaining about? I need it? I need a Record a wild card. So I need to do something like this, right? Oh, let's do it like this. But and then I need it. Yeah, this is gonna be this is gonna be a Mem yeah exactly and at mem like this and Now I need to enable record wild cards Wow, see the editor stuff Yeah Timmy got it also This is gonna be a Problem here is that yeah, so we didn't change the types here. Okay, so this is going to be so we have the memory This is gonna be N We don't update the mask Or the memory is going to be We're gonna do like did it up map dot modify or something did it up map modify Modify with something like that Or now we're not not even gonna modify it with we're just gonna say insert so this is gonna be map dot insert Address Mask val Like that I'll even do it like this Run program Take a list of instructions I'm going to return as a memory data initial memory No, it's gonna be initial memory some memory Initial Memory as we call it mem equals Mem the mask is just gonna be mask equals id Mem equals map dot empty Run program run pro gram equals fold L1 hold L Instruction initial memory Let's see what happens test input print dot run program That's because we would have here You had a nice show class here Let's write it like this show mask MSK equals show Okay, show mask we have that This is gonna so we're gonna say Distance show memory Where show equals Show mask mask plus New line Plus show them Let's see what happens for the test input from list 7 101 864 and I think that's exactly The result so we do the sum here and yeah, hey Solution this of instructions to an inch 64 Solution is going to be So Where res equals run So we're gonna say So this is gonna be we're gonna run the program Okay, and then run the result of that we're going to access the memory And then we're gonna say we're gonna get the elements of memory We're gonna sum them Print solution All right, that works. Let's see if it works for our input or like how slow it is Because these mask stuff that is not a fast way to do it. Let's see here Measure command expression day 14 Out default takes 45 milliseconds to run it That is a bit much right, let's see. All right, we got the first one beautiful Now, let's see how long we're gonna stay today For some reason it must be using version 2 as a decoder ship Instead it act as a memory address decoder Immediately for a value is for the memory each bit in the bitmask modifies the corresponding bit of the destination memory address Oh If the bitmask bit is one zero the corresponding memory address bit is Unchanged if it is one It's over in with one A floating bit is not connected to any thing and instead of fluctuates and particularly press practice. Oh My god Can you imagine, you know, like, you know, we're I mean, I see like we have a lot of computer scientists watching the screen when you're gonna be like You know that the fairy guy the fairy guy would be like is there a doctor on board and you know You got all these medicine doctors and they're gonna be like I'm a doctor and like I'm like no No, we need a doctor of computer science Why because there's floating bits in our decoder chip and we need someone to Fix it before it's too late. And I would be like, you know I've been preparing for this moment my whole life That'll be good Okay, so now we're gonna we're gonna need to change our oh My god, what is this? Version 2 decoder to doesn't my life. It's okay. So if the bitmask bit is zero So it doesn't change zero that it's okay if the bit was one else is floating A floating bit is not connected to anything and instead fluctuates on predictably in practice This means that the floating bits will take on all possible values Causing memory addresses to be written all at once When this program goes to write the memory address 42 it first applies the bitmask So and then the the four bits are all written the three of which are different and two of which are floating Floating bits take on every possible combination of values with two floating bits for actual memory bit memory addresses are written sheet Hi cracks Nice to see more people Where we just saw part one we're solving part two It like you know because I'm not I'm not getting a like a oh here's a nice way to do this I mean unless we have like a quantum computer I Because I'm just thinking like the one we just have to Simulate it. This is the advent of code like the code advent calendar, and we're solving all the problems. We're on day 14 We'd solve part one and now we're gonna try and solve that part two and then we're gonna move on to part day 11 because Yeah, I was traveling so we didn't we didn't finish that okay Floating bits take on every possible combination of values with two floating bits for actual memory addresses are written Next the program is about to write memory to the 26th with different bitmask Whoosh So, okay. Yeah, but the program is about saving the ferry that Santa's on from crashing Okay, the entire just still being initialized to the value zero at every address I still need the sum of all values left in memory at the end of the program Okay, we're not gonna be doing these through the map, okay, what we're gonna be doing We're gonna be taking every single memory address We're gonna be mapping the masks to them and we are gonna try and figure out like the last Modification to them do it. I think that's That's something right because like these floating bits like they will clash They will they will clash some way You know because we were not good at bit manipulation. I mean so we could I think we could we could brute forces, but Too much right? Let's see the input is the same, right? Let's look at our input Yeah, you see this is like 575 lines of code, right and Oh, sweet. Let me just reply to one message. All right It looked like monkey Who is monkey your voice audio is behind by the way. Oh, that is Let me let me let me do let me do one thing one thing only Thanks for take for noticing yeah, because I can I can't delay it I Can say a render delay and I can say Let's see. Is it is it 10 milliseconds? 15 milliseconds Is it better now a crisp cracks? Like does it match my voice I Didn't notice this in the video I took so so is it okay. Let's let's do binary search It's a bit better But it's still like it's still it's still behind, right? Let's put it up to 25 How's that I can do better Yeah, I mean that's what I'm saying to me. I mean that's like I that that will work But that is That is That's like something we don't want to do Okay, let's let's begin by this is a Haskell my favorite programming language and Many others is favorite programming language as well. Let's see. Uh, let's see. Let's see what happens. Let's collect So I think what we want to do You want to collect all the masks So kind of like what like for each mask What are they gonna be turning out to be? Yeah, let's see Do-do-do-do-do-do-do I mean on the test input, this is gonna be terrible right like literally gonna write Into every single address Okay. Now first of all, oh No, we can't de-duplicate Let's see can we de-duplicate in the input like is it often writing to the same thing again again doesn't look like it So let's think about it. Yeah, this is Haskell What I just said right the Haskell programming language quite a nice language Like like this is not a language. This is just the input we have for our problem This is the language itself Okay, let's think about this So the amount of X's The amount of X is in the address Will tell us how many times so so here we have like if we have one X It's gonna be repeated two times. So we have Two X's it's gonna be repeated four times Because there are four possible values So so it's gonna be so that's it's gonna be like that right to to the power of number of X's in the mask In how many tabs have you opened? I don't know man. I lost count one One two three four five six seven eight nine ten eleven twelve thirteen fifteen sixteen seventeen eighteen nineteen twenty twenty one That's how many tabs. I'm on right now okay, so Let's count the number of X's in a mask So let's look So cuz like cuz like we count a number of X's in a mask So the thing we have to be careful. That's about clashes Do You see what I mean to me right so this is gonna repeat hundred four times In memory and this is gonna repeat one Eight times in memory So result is gonna be four times a hundred Plus eight times one which is four hundred and eight Okay, but the issue is that some of them are This will return right to eight addresses, but some of the issue will be that you know some of these addresses will clash a That's the that's the key trick Let's let's look at it So this will not be this anymore Not just the max Mask function is going to be the actual mask It's gonna be actual string. I'll just call it string And then here we're gonna pass pass mask and we're gonna say msgr it's gonna be Many one like this and then it's gonna be msdr uh msdr Masking for the mask msdr Instruction and this is gonna be mask Of this comma mask So, okay, so this is actually gonna be a not a not a string. It's gonna be list of maybe Let's see And it doesn't like something here Yeah Okay, right so for solution one this is gonna be So run instruction mask f F comma x It's gonna be fx Let's just let's just Let's just not do it this way. I think we should just kind of start over for part two Because it's just kind of completely different stuff We're gonna be doing Okay, gotta get input two So these are gonna be uh Let's actually not do it like this Let's just start a new file called day 14 Part part two dot hs let's uh Copy and paste it We name it to day 14 Part part two, okay, so now now the mask is gonna be Oh nice Always get to have uh little brothers and do that. Uh, let me have some candy Yeah, I know watchdogs. I didn't I never played it actually um It's like too much of a triple a game Meaning because like I usually like I have laptops and like you know computers optimized for Kind of running code and that usually doesn't include such a good gpu So I have a hard time playing all these nice fancy games That's it. Why don't you figure out which ones are overlapping? It's a real question here Okay, so We're just joining us. We're doing part two the advent of code We know that we could just emulate it And just run it and we'll probably run like not not slow A couple of milliseconds or you know Less than a second But uh It's uh, it's turkish pepper The thing is that my dad doesn't eat candy So he sometimes just leaves like random bags of candy on my desk, right? problem is that I don't live here anymore I don't really like turkish pepper either But now I have a bag of it on my desk like You know, you remember the the pear peyo sugar Like the Icelandic Candies that was the best Turkish business almost like that except they had like a pepper core But I'm like, you know why Why are you like this? Okay, oh nice Sure. I mean just leave the link. I'm not gonna play it right now But you know, we leave the link and I'll catch up on it after the stream It's a hard part about Programming, you know When you're like, you know, you know what you want to kind of want to do but You're really trying to figure it out Yeah, I will I will See so So we we will get four times whatever it inputs into that memory But then we need to figure out How many times will like clash so we can We can uh, can we like reverse engineer? Like go in the opposite direction But then like we have to add all the keys to a set Can we like take a mask and check if an address is covered by it? Because that will depend on the addresses too, right? Okay, let's uh, let's flip it and reverse it Yo boy I wish I could play more songs here I can only play these lo-fi things from this guy Harris Heller Because it's like a it's like copyright free music. So I actually have like a so What do you guys want to listen to stream beats edm lo-fi or synthwave or hip-hop. That's the That's the options we have Is now we're gonna engage thought to mode. We're gonna we're gonna we're gonna go edm We have to think Like if I was just programming. Oh no, I shut it off If I was just programming right now regularly I would like blast some rihanna right now I love like 2009 2010 ish Pop dance music I have the worst Worst taste in music, but you know, I'm proud of it I like it this stuff Wow villain beatle is rating with a party of four Welcome party Hope you enjoy the show. It's mostly me thinking about What I'm trying to do here And what I'm thinking is So this so okay, so the thing is here, right? This address here We have this address here, right? Or this mask. Okay. I'm like thinking, you know, we can Yeah, yeah so I mean, we know how did we know we could just simulate it, right? But we're trying to like reverse engineer it To get like an o event solution The next thought is, you know, we could like walk backwards in the input But look at this mask What are we thinking? If the bit mass bit is one the corresponding memory address bit is overwritten with one So the the the the so if if If anything is covered by this one covered in the sense that That these x's so I said I would do a marathon stream today, right? And I would like finish this days and 11 day 11. I don't think we're gonna get to day 11. This is This is a hard problem You want to do it properly, right? so only these bits will matter zeros Because because the the other bits the ones and x not the x's and o's the ones and x's Yeah, it's the problem statement Here is We have a mask Then we have a memory address and We're gonna write to this memory address uh According this value according to the mask But we have these floating things so that like the x's they take everything And they change them up So that's gonna be a it's gonna be a mess So let's let's consider let's consider here test input Let's let's let's just let's just make test input part two test input two It's gonna be here now Let's look at this so 42 is equal to We have a 26 Let's just copy Oh my god So the thing is that this isn't quite as good as the input In the sense that So here we have the mask right and if this were if this were one like it will always be turned into one below So the only bits we have to look at in the Addresses What is the What is this supposed to be one? I forgot to say that here. No, it's here. Okay, so Also into the power of 264 is not gonna be No, okay, it might be no, it's not gonna it's gonna be it's gonna be big Uh, let's see. I'm gonna go grab some water See the idea is That okay if if the mask has a one in it so then and Then we don't need to look at that bit So how can you optimize that? Icelandic water is the best water Okay, let me see So we walk backwards Now I have to stop you You don't like Icelandic water You know, there's a reason we all left Norway to live on an island in the middle of nowhere And that's uh, mostly the water, you know I mean some people say it had to do with taxes, but I think it was actually in the water Uh, I prefer Icelandic water to the Norwegian one actually I lived in Norway for like two years and Yeah, I just like my I you know because so there's a saying in Icelandic Which translates to you know Never was Iceland loved as much or nowhere was Iceland loved as much as in Copenhagen Right like when the students went to Copenhagen to study That's when they started loving Iceland, right? So the thing is like because because I live in Sweden now I live there for five years and I'm like I miss Iceland, right? So everything from Iceland is the best Okay, so we're gonna be walking backwards through the program. We're gonna be figuring out the space Of that the space each mask covers Okay, and then Then we only let me look so so then we so like for the for the first part We add all of them like as many times as the number of x's in the number And then we go up Let me let me see Let's see. Let's see. Let's see. Let's see So first let's uh, let's Let's actually so we will parse it Uh, but we were gonna parse mask As just many one, okay So this is in the part two. So we're just gonna be Modifying stuff here. Uh, this is gonna be A list of maybe more Uh show So this is just gonna be Then we're just gonna be we're gonna be Deriving Do not drink and derive Huh So we're gonna be deriving this, uh, try parse mask Mask many one. Okay, this is gonna be and now this is gonna be mask Uh Parse many one parse mask info Yeah, this is just gonna be many one parse mask info Parse mem op that's gonna be the same So parse in try parse mem op mem op This is because this is gonna be This is gonna be a parsing Uh mask equals and then it's gonna be mask Over this Okay, and now let's uh, let's Look at them. We're gonna remove all of this. This is no longer relevant Uh test input to Nobody's gonna print it Okay, let's see Oh, this is the wrong one Part two Got an exe Okay, we have the masks and let me have the mem ops Yeah I mean, you're probably from the north, right? I think I think that's why you think the water When the north is good. I was raised in Reykjavik water, you know, it's my My breast water So this is okay, so let's parse these into blocks So what is a block? A block is gonna be Data block is gonna be A block and it's gonna be it's gonna have a mask. I'm just gonna be a maybe wall And it's going to have Mem ops Instruction this is just gonna be a list of pairs 64 comma in 64 Let me write deriving Deriving show Can't shower in Reykjavik I for one love it when my skin gets torn off by the sulfuric acid Nothing wakes you up like some sulfuric acid in your shower, you know List of instructions to a list of List of a block two blocks is going to be a We've written this split add function before let's just grab it. No, I'm not here As before I used parsers, you know, I was doing these split ads. When did I do it? Split when all right, we're gonna copy paste split when they should really be in the standard library, but you know Two blocks is going to be Split when his mask Uh Oh, no, and now we now you want the mask So this is gonna be x No, damn it We're gonna pay you essentially. Okay. We're gonna rewrite split when So let's see here where Is mask mask of anything equals true Is mask something else is false so we're gonna say In this is going to be like comp case break Is mask of so This is gonna return us to to to to to to to So this is gonna be first one's also gonna be a mask msk find it to A list of instructions So and then we're gonna say case break is mask ins of First comma rest that's gonna be block Uh Block msk Uh first Uh, so here we're gonna say to uh to to pair Pair, uh mem up Uh Equals e comma b and we're gonna So to pair of learning else is just an error Not of light to mem up So we're gonna take the first and then we're gonna take the rest and we're gonna say map to pair of the first And this is gonna be concatenated to two blocks of the rest Uh first And if we if you don't have anything here No, this is just gonna be like this actually where So we we're not even gonna say here We're just gonna say like this and then we're gonna say This applied to the rest And it's gonna be two blocks Of an empty list is gonna be the empty list So let's look at this Yeah, the swimming pools are Legit, I don't I don't really I don't want to go to swimming pools right now. I'm also in quarantine Literally illegal for me to go to a swimming pool right now So now we have the blocks Now let's reverse the blocks Okay, so now the first block So what I was it was nothing was X No, I moved my keyboard screwing up my entire setup here Let's see So I'm looking at this But we still have to figure out the In previous days the input has been designed such that there's more specialized Are we sure that there will be an address clashing here? No, we're not actually sure You want to test it That would be funny, right? Okay, let's just do that Uh block So block some That's gonna take that's gonna take uh Oh, this is a blocks Returns in 64 It's gonna turns an integer actually. Let's just do an integer here block some of Let's just do it for one block and then we just sum up for all of them. So it's just gonna be a a block where so num nothing equals Length of the mask minus length Length filter Filter is just because I don't I don't want to define is nothing so we're gonna say Num nothing Times So we're gonna write the memory operation to memory Let's say let's dedupe the memory operations Do we have a nub by? Yeah, uh D duped equals nub by Compare so it's gonna be equal On Second now on first Not function on So we're gonna dedupe num by first on a mem Memops So this is gonna be a num nothing No, it's gonna be two to the power Of num nothing times Some Dollar map As in D D duped and this doesn't work because Okay, oh this needs to be imported Import data.list and Problem here is that this is Not an integer, right? now this says Good national type integer with You say will we will there be Address clashes and I think there will be right? Because we got that was from the first problem right we got 408 Yeah, yeah, exactly. There's a lots of clashes. So Let's grab the mask function here Okay, we don't have to grab it These people you're always trying to sell trying to make me become famous I don't get it. Okay, we've nubbed the memops So can we just like haven't had a set of Addresses which are not covered because we don't like like we don't have to simulate everything But let's just let's just do the kind of the weak thing And grab the covered thing No, we need to figure out which ones are I don't need a Yeah, there are a bunch of clashes right. I mean we already also we saw it from the test input, right? That's why it doesn't sum up to 408 Because These are already covered. So I usually I used to be a linux user, but then I I turned to windows for because my work machine has windows and I couldn't do a boot And I just kind of learned how to use it But I've been using vsl 2 a lot on my other computer, but like I'm not allowed to update this one to the Like windows 2004 or like the the version windows 10 version 2004 which allows me to use proper vsl 2 So while I'm waiting for that. I'm just using power show, but on my home computer which I have full update rights for That's where I can That's what I can I can I can do it there, right? Let's see I you know, I'm just gonna I'm not gonna simulate it by running the instructions But I'm going to do something Uh Something similar So Let's see here You go to update check for updates And you know you click this button And it will say that you can update if if your organization allows for it, but uh Yeah, it just says up to date and it's like Managed by organization so I can't Can't fix it I press press a windows key and use search for update Up Check for updates Keep your keep your machine up to date It's important stuff, you know addresses equals map first memops I'm gonna have Yeah import data dot set There may be problem. Maybe you know, maybe there's like a nice Way to do it, but not for me sad dot from list Addresses set from bomb list Well think for the follow X message I bet X message is a Linux user Oh sweet Okay Uh Yeah, I mean I I managed to do it on my other laptop or my other computer, but But uh, but it uh It was illegal or like, you know, I I'm not allowed to change that setting on this machine Which is very annoying frank frankly Okay mask mask two addresses it's going to take in a maybe Unless the maybe bull bull turn into a function in 64 to uh set In 64 Okay, so the floating bit so the So sip zero dot dot um Where's mask? Okay, so map, okay, so and then we're gonna say here where have A pair of I come up so if I if I it's nothing then it's an X. Okay if I was zero It's gonna be ID that doesn't so if that is unchanged f is equal to I comma Just true then it was one now this was just false just true was gonna be Flip set bit I It's just gonna be Set that single turn Of a what is it saying here? Oh so let's just first apply the Let's just first apply the The the ones that just set it right That that will that will update the number So let's see So that this will give us a function from In 64 to in 64 So the funk will be uh funk takes an I 64 And he will say Okay Sip zero on the reverse msk msk, we will Just it and it's gonna be just Just it this is gonna be and then we're gonna Map maybe have You can see Where base equals Base high 64 So first we apply the base Functions to get the actual function that we're going to be looking at period dollar Of uh id dollar So then we let me have the number And now we have to look at the changes we're gonna make Yeah, so this is gonna be first a Num to work Work with equals it's gonna be base High 64 so that's the number we're working with And then we're gonna be flipping the bits Uh So so here we will have a X loax is gonna be map fst of A filter A knot is just Of Of uh of the So we're gonna take the second Second not is just A map first second of the mask and uh No, this is the mask. Yeah, so this is gonna be Masc ins Masc ins Masc ins Now for each of those indices we want to create We want to create the set of numbers that it generates It's gonna be exponential, right? And for the number of x what music playlist are you listening to this is harris heller's Stream beats edm music Uh, it sounds part of it and uh, because like twitch has been doing a lot of dmca's Recently apparently Um And uh, I don't want to be hit by one And also like this is like, you know, it's okay. So he has this playlist called stream beats edm copyright-free electronic music And then you know my Also You know my youtube videos of these sessions are also like they're not taken down by the mca's and stuff Okay, so I will generate Okay, so x looks up the x look It's gonna be so empty and then so far is gonna be so far Up the x look I so far I and then is It's gonna be that's gonna be a map set dot map set bit Uh Flip set bit I uh of so far And so up the x look is going to take in a list of ints and it's going to take a list of set int 64 And it's going to return int set int 64 And it's going to be set dot union And then we're going to clear the bit clear a bit my god No, I'm doing the thing again where I press the wrong button and Yeah, this is supposed to be so far This is going to be funk This is just needs doesn't need to be in the function itself This does not need to be in the function itself Oh, yeah, no, which is also has to be here So this is going to be up the x look of the x looks Of set dot singleton None to work with And this is going to be funk. Okay so data block process Okay, let's see So here we generate all the addresses So for each address we generate The addresses you can go to Let's see So this is going to take in a block and it's going to take in a set int 64 integer and it's going to return set int 64 And an integer Okay, now let's let's let's let's look at this first, right? But no, let's okay. Let's let's do it. Let's just just do it roll with it set int 64 comma integer to set int 64 comma integer What is it going to do? So we're going to take a A Covered and we're going to take the curve some So we are going to say okay, so Adder funk is going to be mask to addresses of the mask And you find So that's the address function Okay, if anyone's here is Game of Thrones The young Greyjoy and Tyrion Damn I have no comment, but that's a bit funny, right? So We're not going to be using this we're going to be using dedupt So we're going to say here fold l prime add and update In it In it a and then dedupt Where oh, wow, thanks for the Oh, it's nice Add and update that's going to take the the the covered And the current sum and it's going to take in Uh an address and a value It's we're going to say Okay, uh So, okay where adders equals Uh Adder funk address set address set Set of the address, but we are going to say We're going to say a set dot Difference So this is going to be yeah, so this is going to be set that difference without covered For nested wear closet. Yeah, I mean this is where we're scoping things here, right? Okay, so We're going to add and the new set so total val added Is the length of adders times val a new A so covered prime is going to be Uh covered Oh, can I say like this joint union and that's pasture this joint union Uh, no, okay. That's calculating it Okay, this is the same union Uh, this check is subset of now. I just I'll just say union covered set that union The address is going to be Curse sum plus total val added No, uh This is going to be covered prime and this here is address set Now it's complaining Uh that the return here is Wrong Yeah, so we can't we can't fold this here So Let's flip this around No, we don't need to flip it actually this is going to be This is going to be a print of fold l prime of flip block sum On the initial value is set dot empty comma zero Let's see non-accessive patterns in function f right f of anything else Nothing. Yes, this is Uh, okay. Now we have 202 We're supposed to be getting 208 Uh Okay, let's let's see here What is wrong here? So it says we covered addresses 26 27 58 59 Yeah, that was the first one, right? And then it's supposed to cover 16 17 18 19 20 where 25 26 27 Is it because I forgot to reverse Nope We are reversed Well, you can compile haskell to javascript, right? So, you know You can just do what you want. Let me see now. We're gonna be doing debug tracing. Whoop whoop We don't use any of these import debug dot Trace Checkmate simon Why would you checkmate simon, huh? Trace show it Oh my god address set No, whoo Lafoo Trace show it Let's see. Let's see what's doing Yes There were trolls all along Okay, so it's working But only for one of them Uh So it's working for this one Why is it only generating 58 or 59 so address set so something wrong with our address set function here. Let's see Mask to addresses Okay, now let's look at the uh, let's look at the trace show idea of axlux Yeah, he's supposed to meme on twitch, right? You know So I I I wish I Yeah, it's gonna sound bad, but you know, I've tried to uh Be like Every time my it doesn't work. I do like f in chat, but then It usually works But you guys you have to be spamming the memes kappa all that all that stuff Okay, so the axlux work Yes You know what? If you're gonna be recursing Make sure you actually recurse yeah, so It's gonna be Where so far prime equals Okay, let's see So that's gonna be up the x-loak is So for prime does it work? Yes We get 208 And look we get all the addresses and Um, yeah, let's see Let's see how bad how bad is it measure command expression Can you imagine if I was in? Linux right now I could just Not write these things 51 milliseconds See now it's like oh, you don't need these That's true, but like here like here Is it gonna work? No Why are you telling me? What is it? Oh, okay like Yes, I can do this but Sorry, I just I don't want this blue line here And here it's complaining that It's just function. Uh, it's complaining that Is nothing. Okay. See now now I'll say is I'll say is nothing Okay, that is in data maybe okay, but in base Pogs Vsl2 let's spindle subsystem on Linux 2 And the absolute mad lads over at microsoft They just have an actual windows kernel A linux kernel running on a hyper v Like they're virtualizing an actual linux machine on your windows machine And then you just like ssh into it and then like vs code will be running Like running on my windows machine, but like it has a remote connection to the Vsl machine So it's super fast And you get all the goodies of actual linux, you know because it's in the actual kernel So like even weird programs that use like kernel functions They work They are going to Add gpu support soon Uh Why I'm not using it at the moment like I've said before Uh, you need to update to windows 2004 Or windows 10 version 2004 But uh, I am not allowed by my organization To do that so I can't do it Yeah, I know I would do it, but it doesn't work So once I'm allowed to update this to the latest and greatest windows I can finally go back to that But you know, I don't have I didn't I bring bring my desktop all the way over here. Can I get an fn chat? Okay, so I think what I'm thinking Is that this is not too bad? We we're just taking set unions and stuff And then we're only adding things if we need to We're not like building the entire map or running the entire program. So this is kind of like the Program analysis way of doing it Oscar Allen, the they're the only one Actually They're actually like the the other ones are just on you know twitch to watch this content, but he's the twitcher, you know, he's um He knows what it's about Okay, can I uh, so this works On the input and the time to beat Is 220 milliseconds Let's see. Let's uh, let's remove these addresses. I mean they won't be used if we're not actually using it But it's gonna be fine You can use my new emoji you got accepted this weekend. Are you are you all ready? Are you ready? All right, this is the new emoji if you don't understand something in Haskell Just go treat low. Hmm And has the Haskell logo with a hmm on it I stole it from suri hack Well, like I I stole it from the I stole it. I I borrowed it from the suri hack discord server It is so good. I just want you to go forth on twitch And like every programming thing just like why aren't you using Haskell? Hmm I love it Uh, I I love it. So this is gonna be fast. This is gonna be fast Now let's remove these trace show IDs This here, however It's not going to be fast Fold l compose over something Let's see how it does on the input and If it's taking so long That we can't wait then we will stop So where's the last debug trace trace show id it's here Some actual drops in these songs. It's good. Okay, and then I don't actually use this Oh, thanks for the follow You know, I appreciate all follows They are they are nice mona tutorials they are Yeah, there's something you know The real mona tutorial Is always in the comments. No, the real mona tutorial is to realize that Monads are just What they're just an end of functor in the They're an end of functor that are monoid in the category of end of functors, you know but I think, you know, if you if you so like when I figured out monads if I can say I've done that was when I Realize that there's nothing to figure out You just use them Exactly, you literally just use them and you read the compiler errors And if you fix those errors The monad works so Just just do that Okay, so this is gonna We're gonna rock it We're gonna rock them sock them Oh, are you ready? It's gonna take Take a bit longer. Oh Uh, I didn't I think there's some debug trace there Can I get an f in chat Because my editor just froze Oof What did I do wrong? Let me let me Let me uh Am I are you getting frame drops and stuff now because Am I just not broadcasting anything anymore? God damn Videos still good good stuff Okay, that was fun But uh This is why you need to test Eh Let's run it again. Let's run it back On the test input. There's some What is this from list? Oh, is it because I I'm oh my god But you see it finished You wouldn't have started printing that list if it hadn't finished, right? So it didn't take too long. Wow 25 milliseconds on the test input I got I got impressed for a second there Uh, but I was too impressed So we got the list of literally every address Okay, uh 200 milliseconds Is this correct? Let's see That's not the right answer Oof Can I get an FN chat? Damn it Oh my god So we reversed the blocks And then we only add the ones that Let's let's let's make sure we we actually reversed the blocks Uh That is a bummer. Yeah Seemed like a Way to go right So this is The mask And then it says 6113 6116337 And let's look at our input 66375249 And this is this is we did reverse it It compiles it works. Yeah, um I'm gonna take One minute break I just need to get over this You know, it's too much Give me a sec. I know What the air is I know what it is Uh, so because So it applies memory operations And The thing the thing that we're doing wrong so We only update the values that are going to be updated But what we did wrong is that we didn't flip the memory operations within the blocks, right? So if you get an overlap later in the block from something that's what we didn't flip so So here we have the up the x-logs So we need to we need to take care Uh We need to we need to fix it We need to make sure that it does it correctly. So this is mask to addresses So add an update So are we Reverse I think that's the issue Let's see. This is not the same number as before, right? We said something like this I think it's gonna be this All right We were missing one more reverse Dammit. Okay. That was I was yeah, all right. We did it The thing is that we so we because we reversed the entire thing, right? So we did per block But we forgot overlapping addresses within blocks That would always resolve to the last one What time did I get a 127 milliseconds? just the program but but Yeah, around 120 This is actually faster for some reason Then the one where we did we didn't reverse him I don't know. I don't know why What if we can we can we optimize it a bit? can we just say In 64 here Total val added And then this is gonna take in I think the That's the issue slightly. Well Okay, that didn't change much Uh, yeah, we can do this fix So we did it it worked it took you What 0.8 seconds? It took me you Uh You said 220 milliseconds, right? Something like that. So you did it. You did it in point 0.08 seconds, that's That's 80 milliseconds, right, dammit a That's pretty good We got it in 120 but I think maybe you know if you do it with data.map and you use like the lazy map It like it won't do anything unless you when until you actually Sum the elements in the end And then like all the lazy updates will just have been you know, like, oh, I won't update it here I will just have updated it with the exact value that it ended up being with And like we're essentially we're essentially calculating all that already Let me see Let me see data.set data.set Haskell yeah I'm a bit disappointed in the that that it's not Not as fast I have to admit boom boom boom boom We could We could we could try something It's a universe yeah Oops Yeah, you see I have 1909, but I need 2004 or to work Yeah, I think that's gonna be it I don't think we can I mean, there's not so many just not so many many There's not so much we can we can fix here, right? This is just this is all just gonna take a lot of time Let's see a maybe if we can do the set bit and that stuff Put it out a bit But uh, yeah So let's see So I'm I'm thinking I'm thinking about this set set flip just flip set bit just Eight I'm thinking if we could just like generate the one Yeah, yeah, so you need to like update the vsl some way Uh, you like to do you know, I think you kind of need to remove the old vsl and then update the vsl to make it work Let's see, uh Yeah, hold l I'm that's not That doesn't matter right 110 milliseconds sometimes I think it's also to me that You're like not running obs and everything at the same time that might might be it. I think it's hard So I think we have like the same order um I was just wishing that that this would be a bit faster Because we do avoid doing a lot of computations, but then again, it means It means that uh You know, I'm doing so much so many set operations Which the which don't really matter like um Because I like I like figure out exactly which ones I'm going to update and then we And then we add the value with that also But I you know, I think there is a way to do this Using some clever bit tricks you know by Saying okay, what if what is what is x? So if you want both values you do you you you add 64 to it and then you you Remove 64 from it If it's setting that bit So you could you could flip it, you know, there's there is like some Definitely some clever integer bit binary tricks you could use here But we're just not seeing it Let's see, uh Fold l So base is this so fold l id map maybe We're gonna be applying that all the time So Let's do here Let's apply this to zero bits what and Oh Bid is gonna be So base applied to zero bits And then num to work with That's going to be Musk ints This doesn't need to be in the function right map maybe f So base is going to be a function from int 64 to int 64 And bid and then this should be num to work with Is i 64 i think it's and then we do xor with the bid that doesn't change anything We still get the same answer. Yeah, right What was our answer? No, this is the wrong answer because we want to do We want to we want to do not xor We'll do dot and dot Then we set all the bits to one. This is still Wrong answer, right? Is the right answer but that doesn't need to be also This can be out here And actually this is all I mean all of this is not specific to the integer itself So we can do Here Yeah, I mean we're always around that mark, right? Like 120 ish Yeah, I was just trying I tried to change it see if it like helped But it didn't change anything So the fold l1 is strict and like we're going to need we need the results of everything so I'm like, yeah But this here thing is always going to be Exponential right or like this is going to take a lot of work to calculate this So yeah, I don't think we can boost the boost the I mean, it's definitely like I don't I don't think we can do this in any faster runtime You know not without figuring out how the coverings work Without doing set operations. That's just too much, right? Uh Yeah, so let's uh Let's I think I'll call it a day here. I was gonna do one day 13 Or day 11 So what I'm gonna do now Is I'm going I think I'll take like a bit of a break And we can continue with day 11 after this because like Uh, that's my plan for the evening But I'm not gonna take like an hour break and uh I'll I'll take a break for about an hour And then we'll be back at like nine o'clock UTC And uh Yeah, exactly timmy. I mean we're not saving anything. So Yeah, I'm gonna go offline now for like an hour And then I'll come back and I hope to see you all then Uh for some more Item of code to do day 11 Because you know, I I'm gonna have some dinner drink some water You stretch this and tread out of it. It's been a three hour session. You know, it's quite a lot All right. See you all in an hour