Advent of Code(x) | Day 3 - Rust | Using OpenAI's Codex to solve Advent of Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome again to the third day of the advent of code i am recording this after a previous recording where i could not manage to get a solution after about 15 minutes and i stopped and went on about my day and now i'm back to try this again and i hope that a new approach will bring new success so i start again by copying everything and into the default replica file now into the playground yes and now i'm changing my prompt to three um quotation marks and i'm going for the rust syntax highlighting and i'm going to revert that and i'm going to put the signature of the main function in rest and changing the response length and let's hope for the best so the input syntax and i'll probably have to remove this dot dot slash because i will keep this on the same level because i'm not even sure how to do this differently on vapolite otherwise let's see if it does as it should be doing and the rest specifically the calculation so copying it all the way here and pasting this here so as we said i am changing this because we will keep this on the same level not one level up i'm adding as the file this example input and put in lowercase input.txt all right so it doesn't recognize the file just yet maybe it needs a moment let's see what happens if i run 198 all right now we know this is the right answer so i'm ready to take the puzzle input copy the entire thing and move it into my input file and run overflow well that's not expected i wonder is this the last line here yes can it have more than thousand lines yes what happens if i just go back and try again well it points me here into this line and i suspect this might be related to the fact that the input example has something like ten lines and this has something like or exactly one thousand a third main panic at called result on wrap on an error value run with this environment variable to display a back trace not sure i want to backtrace let's see if i can i'd expect that if i will remove this it might not behave as i want it to and if i do remove still this i will have to remove the whole thing so keep just the instructions and not leave anything from the from the example explanation let's see if that might work i can see again that this is a higher level and accessing the text file which is not what we need i'm just going to comment out this entire thing so i can get back to that because i don't have high hopes for this oh and i need to change it and let's see five nine seven one i don't assume this will be the right answer but let's try five nine seven one that's not the right answer too though i wonder if i don't change almost anything and i will just write the function signature in a partial way will i get any better performance so it still recognizes rust which is great the input file still assumed to be one level up which is not a big deal overall it looks somewhat similar to what it did so still keeping the previous solution which worked mostly fine let's run and see if i get something that is not five nine seven one same error what looks like it's might even be the exact same solution and now it goes to line 34 so i just change this one line it will be in line 33 and that's exactly where we had the problem last time and just for fun if i change the definition of epsilon and of gamma i will probably still see there in line 33. yes so looks like the rate calculation is not correct or not enough so what i will try now is to use the ai to try and understand this explain this rust function to me it does not explain let's see if i can use instruct engine instead this function converts a string representation of a number okay into an unsigned eight bit integer okay the number is represented in base two so string 11 will be converted into integer three cool then i wonder why it does does not work it takes a string so it converts a string into an eight bit integer in base two and it says that it fails to do that the way to set environment variables in every blit is here got it key this one and value is this one okay let's see what happens when i run well i can get this more verbose but i'm not sure it will help me i'm looking to see which of the variables have been already in use or where have they been declared so i can replace that with just a number and then it might help me understand what is happening exactly so i'm looking for now that i know that it converts a string where is that string where is it coming from so this is the input file now i'm counting how many lines we have how many numbers and let's counting how many so this is the calculation exactly for each one for each of the values just like this algorithm said so it's really in the conversion from string to to to binary what i wonder if i will truncate my list into 10 numbers this should work because it worked in the past now that doesn't even work on my list i wonder if the numbers that i received are longer than the numbers in the example and that's why it's like that yeah so it looks like it's not the length of the input but actually the number of digits because this is 5 and this is 4 four twelve well that's already nice guess i'll start using each part of it with the code explainer and see when can i figure out what's happening this one is closed here this is um okay let's try and understand this one and now what i have i have a different engine that i'm using and the prompt has an instruction the function and beginning of the explanation to point it to do this explanation versus actually coming up with more creative code the function is used to calculate the gamma and epsilon rates the gamma rate is the number of times function divided by total okay all this seems pretty not relevant for what my problem is and i know my problem begins in line 33 so i'll try now in line 31. stop all right it takes a value of type and iterates over it mapping each value either one or eight and collects the results into a vector i wonder if this is where we're limiting ourselves no or maybe eight bits yeah this is where we're hitting this so we can try to change that to a 16 bit u16 16 16. is there a u8 anywhere here remaining only in the comments let's see if this is going to work no still overflow but it's in a new line in printing so it wants to print something that does not make sense to it let's begin unwind before panicking i tend to multiply with an overflow so i guess u16 times u16 will be a bit too big i'm going to copy this one and see what do i find it looks like it will convert back into u8 which will be too big for that more than that if we radio over on the expression need to be eight while the final value of this expression would fit the expression doesn't which is why we can find it something so we can write it like this maybe this will be more useful okay i'll try instead print u 16 or maybe it needs to be a 32 and that's why it doesn't work it looks like and this one maybe the multiplication of both stays into the same type but actually the number is just too big to fit in there there it is and let's see that is my answer hooray got a gold star congratulations everyone we made it
Info
Channel: Natalie Pistunovich
Views: 100
Rating: undefined out of 5
Keywords: codex, openai, rust, adventofcode, adventofcodex, no code, nocode, replit
Id: IgexbdQ1AsE
Channel Id: undefined
Length: 18min 25sec (1105 seconds)
Published: Fri Dec 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.