AoC 2021 in TempleOS β€” Day 01

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

5 stars

πŸ‘οΈŽ︎ 7 πŸ‘€οΈŽ︎ u/kapitaali_com πŸ“…οΈŽ︎ Dec 04 2021 πŸ—«︎ replies

It's sad to watch all his struggles with parsing and memory management. Coming from C#, you have so many abstractions and utility methods at hand, that you could solve this stuff with one hand on your back. Perhaps it is the use of garbage collection that allows you to set your mind free and iteratively abstract away details to a degree that make everything gleeful. If people coded like him at work, I'd ask them to re-do it.

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/kbilsted πŸ“…οΈŽ︎ Dec 16 2021 πŸ—«︎ replies
Captions
all right looks like we're live hello everyone and welcome to another zosing session how about that how about that but you don't expect that to happen so let's make a little bit of an announcement before we actually start so uh real quick uh red circle live on twitch and today we're doing a very special topic today we're doing a very special topic um uh thank you so much uh coppercab for 27 months of tier 1 subscription thank you thank you thank you and welcome to our epic temple os club welcome to our epic temple so today we're doing advent of code 2021 i forgot to actually mention it's 2021 in temple s that's what we're doing uh what it's all about i'm gonna get into that a little bit later uh twitch.tv searching and i'm gonna ping everyone who's interested in being pinked somebody sneakily called themselves pingley um and now i wanna ping them right but i'm not going to ping them all right so the stream has officially started the stream has officially started and uh yeah so today we're starting at the end of code and for this who doesn't know advent of code is an annual event where um basically through like starting from december 1st up until december 25th uh you're given one problem to solve right every day and it's like basically the advent calendar right so i don't know anything about advent calendar uh because i'm coming from the orthodox world not from the catholic one so uh i actually like before i learned english and actually started to do advent of code i never heard of such concept as advent calendar at all in my entire life uh yeah so so just something to to be aware of right so i'm coming from a completely different cultural world where this uh is not a thing right so i was actually quite surprised that it's a thing in uh in central europe in us probably in canada i don't know where where it is but in from the world where i'm coming from this is not a thing so i just don't know it's it's basically like an event calendar and uh yeah so we already did this thing last year and uh the challenge of the last year was that i have to use a different language for each individual problem right uh so let's actually start to um you know keep track of the description configs 21 says thank you so much for two months of tier one subscription thank you thank you thank you and welcome to epic temple uh that's right uh so uh let's actually start keeping track of the description so i have a description file from a previous stream so i think i'm going to actually comment it out so the stream was about uh i think it was a port where we removed overloading right so i'm going to actually mark it like this and i'm going to open a new description file uh description id this is a reference and uh in a reference i'm gonna give the link to advent of code check it out advent of code so check it out i'm gonna actually put that in the chat for everyone who's watching live and for people who's watching on youtube you're gonna find this thing in the description of course uh all right so as i already said in the previous year the challenge was to use a different language for each individual day so and i put all of these solutions in this repo you can find it in the description as well uh solutions solutions for advanced of code 2020 you can find it in here and i'm going to copy that in the in the chat as well for anyone who's interested so the challenge of today's year as already mentioned in the previous in the announcement right is going to be solving all of the problems in holy see inside of the temple os uh for those who never heard about temple os it's a very special operating system it's a very interesting operating system it's not like um it's not like a distribution of linux or anything like that it's an operating system that is written from scratch by a very famous person uh terry davis uh right so you can find it in here and uh of course i'm gonna put that in the description temple os so here it is and for anyone who's watching live i'm gonna copy that in the chat so here it is here is the uh here is the link so uh one of the things uh about the author of that operating system is that he suffered through in his entire life i'm not sure if uh the entire life but like maybe half of his life uh from schizophrenia so uh if you want to donate to me this month while i'm doing advent of code consider actually donating to the charities down below in here instead right so there's a couple of charities putting here that do research on uh how they say so let me actually quote them uh organization working on these to pain and suffering caused by mental illnesses so consider donating there instead of me this month um all right so and essentially this entire operating system is basically like a commodore 64 but for a modern computer right so that's basically what it is and what's interesting is that it has a built-in c compiler uh that uh you know compiles uh your code just in time and you can use that c compiler as the shell scripting language of the operating system and the whole operating system is built on top of that shell language and that language is called holy c it's a very interesting concept it's pretty cool and uh it's designed for like modern 64 x86 64 computers uh right so um richie thirteen zero nine thank you so much for twitch prime subscription thank you thank you thank you and welcome to our epic temple um cheers by the way just in time and ahead of time i see just ahead of time okay oh my god this is such a cool idea like develop just ahead of time compiler yeah that's actually pretty cool idea so and uh the whole operating system is just like a single iso file and what we're gonna do on today's stream um since usually the first problem of advent of code is like very very simple it's just like to warm you up it's some sort of like hello world uh i'm not probably gonna spend too much time on solving it so and because of that i decided to spend the first string setting up the development environment right so we're going to start from scratch we're going to download iso file of temple os we're going to set up qema virtual machine we're going to install the tempo is there we're going to go through the tour the temple os by the way comes with its own tutorial there's a built-in tutorial thank you to uh dev teardevs for building that this entire thing so you can go to the tutorial and learn the basics of the operating system so we're going to do that on the stream and once we learn the basics of operating system how to write programs we're going to try to solve the first problem so that's basically the plan of today's stream it's basically the plan uh okay thank you so much everyone who subscribed the fra thank you so much for tweet prime and not not not lift 151 thank you so much for uh tier three two months of your thing thank you so much um all right so let me uh let me see okay uh let's go uvu um to to do two so i'm gonna go in here and i think i already prepared everything i think i already downloaded the iso you can download that iso like by pressing this button and i already prepared everything so in the folder aoc 2021 get damage so i forgot that they installed sl uh so do you guys know what is sl have you guys heard about it so there is a pretty funny uh pretty funny command called sl uh which stands for steam locomotive what locomotive i don't know how to pronounce that word but essentially it's a joke command in case you misspell ls right so you install it on your machine and every time you misspell ls you have to wait until the train passes by through your entire screen and what's funny is that you you you cannot cancel it if you press control c it actually blocks control c there's literally nothing you can do about it you have to wait uh until the end i keep forgetting that i install this entire thing uh all right so we have a temple os thingy and also i have a custom installation of qemo because the key um that comes with debian is actually kind of buggy to be fair like i have always have a lot of problems with qema that comes with debian so i usually just build my own kuma from scratch and install it in the home folder uh right so we're gonna use the qms 6.1 i think it's like the latest table or something like that and let's actually go ahead and try to run the um the iso let me actually start with the team books or something uh get damn it why is that a theme of today's stream i don't really understand anyway uh so uh yeah i accidentally copy pasted what i actually selected so i selected the documentation of a cell and then pressed like a button that is responsible for copy pasting or something like that holy uh anyway so opt i don't mean to do that i'm not doing that intentionally by the way i think i'm a little bit nervous right now uh because it's like you know the first the first advent of code uh kima x system x8664 as far as i know you just use cd-rom command and you just say temple as uh tempo as iso and that should just start the thing oh okay so this one is interesting requires uh half of a gig of the megabyte of ram so i don't remember how you allocate that i think uh let me actually see uh so it's gonna be help uh and can i do ram ram disk so memory um qemu ram how do you do ram because i don't remember minus m okay so i'm gonna do minus m uh in here so cd-rom minus m 512. uh okay looks like it's okay now it's loading compiler uh can i actually zoom in so i can actually zoom in this thing a little bit but can i just make it fit okay so i can actually make it fit so it's loading a little bit slower but maybe this is because i need to set up the uh kvm thingy so let me quickly do that uh so just a second so we need to enable i think uh qemo kvm right uh to the two how do i enable kvm uh uh literally enable kbm okay so for those who doesn't know kvm is just basically virtualization uh or something like that it's just like uses the kernel virtualization thingy uh enable kvm so maybe it's gonna run a little bit faster now uh and i have to do this thing uh zoom to fit every time so i think it loads a little bit faster okay so uh right after off the bat it suggests you to install this entire thing on the hard drive but the problem here is that we don't have a hard drive uh right so and it also suggests you to take a tour uh walrus for walrus wireless thank you so much for 12 months of tier 1 subscription thank you thank you thank you and welcome to our epic temple um cheers by the way so yeah it comes with like this tutorial and there's a lot of like sections in here like the help system how to use the help system the basics editing and running programs i think we're gonna be interested in the part three because that's literally what i want from temple os this month i wanna editing and writing programs i'm not sure if i am that interested in the rest of the things but we will actually see uh we'll actually see so for now i think i need to create the hard drive right so where we're gonna be installing things and if i remember correctly you can create the hard drive um you can create the hard drive by using qema uh image yeah there we go so you can use qma image uh let me see and how do you even use this entire thing qema image uh image so there is a create sub command you provide the file and you provide the size that's actually pretty cool okay so let's do um qma image and i'm going to create i'm going to create aoc 2021 and as far as i know it's usually called just image and i'm going to say 112 megabytes uh right there we go it created an image of the size of 112 bytes i actually need megabytes does it support like multipliers or something like that it does support multipliers okay that's cool um so if i remember correctly uh if i remember correctly to enable actually this is not particularly convenient uh because the camera the camera actually kind of hides everything so it does not allow me to uh easily um you know you know zoom in and stuff like that so basically type this command so it's not particularly convenient so if i'm 12 and um so i think it was hda right it was hda or something like that aoc uh 2021 and there we go uh okay so it's loading compiler okay so it's kind of annoying that i have to do this uh zoom to fit yeah i wonder if there is like a flag that always enables it or some sort of like a um you know option in the configuration let's actually install this thing are you installing inside of vmware qema virtualbox or similar virtual machine yes i am i'm doing that it's normal for this freeze for this to freeze for a moment or two okay let's actually do that uh okay so i hope it found the hard drive i hope it did is there any benefits using kuyuma or virtualbox in linux i have no idea actually i know nothing about virtual machines uh but i just personally like qema for its simplicity virtualbox is just like looks very over complicated i like uma that it's just a single command that you just run and it just works and creates like a very very minimalistic window and that's it uh virtualbox is just like it has too many buttons too many options and just like really overwhelming for me so so right now we're installing uh temple os so everyone what's up hi hmm really let's see [Music] so i suppose it's just like doing so the like territ said that it can freeze for a while so we should not be scared if it freezes or you know stuff like that [Music] okay so it's copying files that's what real installation should be just copying files from one uh you know device to another one that's basically the installation i'm drinking earl gay today by the way streaming is pixelized uh this is probably because there's a lot of moving things uh in here so if i switch to a different window it should not be pixelized but then we won't be able to see what's going on we want to be able to see uh the progress of the installation so it's quite important i could do gifted a tier what's up to sarah moon thank you thank you so much for gifting everyone's up and said moon welcome to our epic temple os club yeah right all righty so is it bad that it's like a red or something like that um i hope we didn't ran out of space or something so hopefully it's fine [Music] anonymous user is gifting five tier one subs to searching community thank you so much for gifting five tier one subs and everyone who's got this up uh welcome to our epic sorting community um so i was gonna do to do to the two for a while like at least like five times so get ready for that [Music] 30 fps by the way console friendly it is in fact uh 30fps i wonder if you can you can get it higher but maybe it's capped at 30fps who knows what language you're going to use inside temple os there's only one and only language allowed inside of temple os okay so it says reboot now uh let's go ahead and reboot so it suggests to load i think it installed it into drive c so we're going to select drive c and uh i think yeah so when it says uncompressed encryption dictionary i think it means that um it means we installed everything correctly and anonymous is gifting another five tier one subs thank you so much thank you thank you thank you um and everyone who's got this up welcome to our epic community all right [Music] right so there is another 10 uh 10 gifted subs again from the anonymous thank you so much for gifting the subs i really really appreciate that uh so what we're doing right now we're just uncompressing the dictionary whatever that's supposed to mean so yeah just uncompressing the dictionary i'm gonna pour another cup of tea while we're waiting for uncompressing dictionary and uh i don't know we're gonna try to maybe take a tour i kind of roughly remember how to use temple os because i already did a stream on temple os uh i think a year ago or two and i roughly remember how to use it roughly so it's interesting whether my knowledge is enough to actually do that uh to actually you know write a program or something like that but maybe not maybe i should not take a chance and just go through the tutorial just to get the gist of how to use the editor and some other stuff so i think it's a good idea it's gonna be good idea okay so you can edit existing stuff and it asks you for a tour all right so i have an idea let me actually try to run this entire thing but without the cd-rom to confirm that uh you know we installed this entire thing correctly so i'm removing the cd-rom and i'm gonna just do that uh alright so it asks for this uh zoom to fit and uh i'm gonna just do that all right so it's loading compiler and uh there we go so it actually loads pretty much instantaneously update and compress the dictionary and whatnot uh and cross24x thank you so much for gifting another subs thank you for gifted stuff i think it's like five subs thank you thank you thank you i really appreciate that so uh there is a lot of com uh like flags in here right as you can see so i'm thinking so maybe i should actually create some sort of a script uh to help me out to run this entire stuff so let's go ahead and do that i'm gonna do run dot sh and in here i'm gonna just like write a shell script uh right so i'm gonna copy paste this entire thing in here and also enable the tracing and the errors right so then i'm gonna do i'm gonna make it executable and now if i run this entire thing it just like does that and that's pretty convenient so i wonder um if i can just make it zoom to fit uh like right away um let me let me try to do that so i'm gonna copy paste this entire thing and i'm going to try to do uh help right so this is going to help and can i do zoom um yeah um remember remember zoom to fit a graphic screen does not fit in the screen so if it doesn't work with display gtk or something like that so there is a full screen option uh right so and it kind of corresponds to um to this one right so if i try to do like a full screen is it called full screen raise it looks like it's called full screen right if i do full screen it starts at full screen so this is a thing right so you can basically provide these options through the command line i wonder if i can do something like zoom to fit and it's not a thing zoom fit it's not a thing full screen is a thing but zoom to fit is not a thing right that's actually kind of sad okay zoom to fit option zoom to fit gtk zoom to fit default it also suggests default uh to gtk options i wish there was like a list of all of the options but looks like uh it doesn't print everything all right so full screen yeah uh full screen toggle full screen yeah i just like wish like give me the full list so i can just basically control effort and find what i want but it looks like it doesn't give me everything unfortunately uh right so they're talking about zoom to fit right so we're getting into the source code it's it's always a good sign when you're trying to find a user level feature and the only thing you can find is the development patches and div it is always a good sign trust me it is very good sign so so zoom to fit uh it is an option grump a grab on hover um it doesn't really tell me how to enable that option though uh it doesn't really tell me uh zoom to fit a command line maybe a command line uh to the two command line uh change look display okay minus display jtk zoom to feed on and off holy that is so obvious that was so obvious thank you so much uh qama developers very cool i really appreciate that and i didn't even find it like yeah it's somewhere in the change looks uh all right so this is gonna be something like own uh temple os is more intuitive than this yes thank you so much and uh yeah imagine that imagine the freaking temple os being well obviously it's more intuitive obviously it's created by the best programmer on planet earth obviously it's more intuitive like why would i even question that i'm sorry uh all right so let's do a run.sh and uh let's add this option in here because i don't want to do that all the time 64. uh and can i just include that okay so this one has to be just on uh there we go all right if i run that uh it's perfect so now we can do c as far as i know i remember wait a second i remember that you can even do boot right uh boot and you can say c this is something that i roughly remember uh no it you can do that whatever uh cool so let's take a tour that's pretty cool [Music] so uh all right so what i'm interested in is editing and running programs right so uh this is what we need and my my camera actually you know covers uh covers everything so let's actually move my camera so behind my camera like i can't see behind the camera either right because behind the camera i have um a terminal right so i specifically put some something behind the camera so uh it forces me to organize my windows so you can see everything so it's kind of like intentionally right so it's a five-head move to actually force me to organize everything so you can see everything all right so we're starting the tour now we're going to demonstrate how to work with programs we'll change to the slash demo games directory note that directories are specified with the forward slash not the backslash drives can be specified in a cd command and the boot drive is specified with colon column uh malloc zone thank you so much 401 subscription thank you thank you thank you and welcome to our epic temple club all right so uh uh enter to complete the command okay so the command here is a cd and as far as i know each command in temple os is essentially like a c function right so we're actually calling to a c function we cd to this directory and then we uh print the files within that directory and that didn't work uh nice one and the reason why it didn't work is probably because i put the cursor at the beginning of the uh of the command like accidentally and if i press enter in here it doesn't actually enter this entire thing and that broke that soft looked the entire tutorial uh just in case just in case i probably want to actually restart everything so let's actually restart just in case because who knows so uh alright so let's take a tour one more time and uh the editing and running of the pro this is not the thing i want it this is so annoying one more time take the tour uh take the tour and okay so it's kind of difficult because i need to first click to grab the mouse and i don't want to accidentally double click because it will start a wrong tutorial okay editing and running programs we started the the right tutorial don't press anything don't touch anything if you accidentally put a cursor here that breaks the tutorial okay press enter finally it worked cool now we're going to edit the file normally you will probably left click on the directory listing to edit a file but we're going to type uh it on the command line so i can't see in this miss but i think i can just do that and as you can see it suggests me to edit this specific file i'm opening this specific file and this is how it looks like all right so i can't see this stuff so i have to keep moving it around this is a first person shooter there is no main function in temple os programs any programs program statements outside functions get executed when you uh include them at the command line uh the castle frankenstein statement at the bottom will run the program when the in when we include it okay that's cool uh press shift escape to abort the editor shift escape we aborted the editor okay now we're on the uh castle frankenstein hc program okay so this is how i can run it i can just include the entire file and there we go we have a we have a game running so this is the game uh move around with the cursor keys and press okay so uh i can move around and stuff like that right so it's a 3d game it's a very aaa game not gonna lie uh okay so then i can do shift escape so i noticed the pattern in here so every time you want to quit something right you have to shift escape this entire thing right so okay uh the program is still in the memory and we can start it by typing custom frankenstein okay so basically it included the file it compiled everything and we now can use the functions from that program so i can run it again and i can uh code it again okay so i can type a bunch of things uh and here i don't really care about them i suppose so i'm going to press ok uh so now i can edit uh okay press f5 in the editor to run the file being edited this is something that i actually need right so f5 so this is what yeah there we go uh then press to kill the task and then can do shift escape to abort the application and ctrl alt x to kill the task okay so it still still have task running uh that's pretty cool so this is probably one of the things like main things that we need we need to be able to cd between the directories and we need to be able to edit files and run the files right so i'm not sure if i need anything else from this tutorial right so i can now create programs and i can now just run them and quit so maybe that's that's enough uh to abort the editor okay explore the demo index you'll find on the menu it's arranged by difficulty hit space on a demo uh okay so i guess that's it right so that is basically it i can barely see the uh the crossing here so i'm gonna just close it and uh off we go so now we know how to do this kind of i'm on the home folder right uh so i want to create the i want to create the folder so i remember that i had like thing here let me actually restart the operating system with a doubt just just restart the whole thing uh because i do remember that they had auto completion uh somewhere here so let's not take a tour yeah there we go so this is the outer completion uh let me actually move my um my thing down there right somewhere here so you can you can see everything and i'm gonna just move this entire stuff here because it's not particularly convenient that it's up there so not kind of not used to that uh all right so can i create a folder make deer uh right uh so it's gonna be aoc 2021 uh and there we go uh so the apparently there's no such thing as make deer or something like that make deer okay so uh temple os i wonder if the google is gonna be useful for this kind of stuff um make folder how do you make a folder uh how to make a directory or file and there's a whole subreddit there's the official subreddit for temple os dear make of course thank you terry very cool in all of the operating system including windows and unix it's make deer but of course here is deer make because well i mean why would the question divine intellect uh dear make uh okay aoc uh 2021 uh all right and there we go so we can now cd to aoc uh 2021 uh and we're there so can i just do that and there we go we have everything so the next thing i want to do i want to create a simple hello world i suppose so i'm going to do ed and i'm going to say hello and if i remember correctly the extension for the uh holy c is hc so i'm going to just use that and there we go we are in the text editor so i have no idea how to program it but roughly from some clips uh that are probably monkey tos right i remember that you have to do hello world like this you can just put hello world like a string and that will just work right uh right so and i can do something like f5 and there we go we have a hello world would you look at that that's actually super cool uh and then can i do shift escape cool so we wrote hello world would you look at that so how much time did it take us to actually go from like zero to hello world uh right so it took us half of an hour half of an hour like think about the usability of the operating system right well i mean i used this operating system before but it was like more than one year ago so i forgot everything uh right so and now think about like how difficult it is to get into the linux right so how much time you have to spend to actually set up everything here i just installed this in think this thing and in half of an hour i have hello world easy freaking easy [Music] so let's try to actually do other things can i like have a loop for by the way can you see the like the programs that i'm typing because the the font is actually very small it's a font for ants and i'm not sure if i can increase it i wonder if i can uh so let me see can i just zoom in [Music] um i don't think so no i don't think so no it's it's just basically it but it's probably because it's uh yeah zoom to feet it's not even oh my god this is so bad right so it was not even checked in here i set this option outside of the ui and in the ui it was not even set even though logically in the program it was set anyway so uh can i just do like a classical thing like in c where i just iterate like ten times um right and just print hello world ten times uh i wonder if i can just do it like that uh okay so it's gonna be f5 and something went wrong something went horribly wrong let's see and defined identifier at i oh boy oh yeah you don't have int or something like that uh i don't remember the types of temple of holy see holy c types let's take a look at types language is the analysis of holy see there is an example of holy c on rosetta code would you look at that the uh all right so holy c uh okay so 100 doors i suppose it does have loops there so we can steal some stuff from this example uh let me oh my god why does it take so much time modern web modern web is unbearable like okay um so pages in the category hello c not hello c holy see okay uh this is a really bad website holy uh all right so hello hello hello holy see why you keep saying this hello c all right okay so yeah you you have this like u8 i8 i64 or something like that and i think you cannot define them inside of four right i think you cannot define them inside of four but i'm not sure okay so i'm going to try to use something like i-64 and i'm going to try to run the program and it still doesn't run so probably have to define the variable outside because i don't quite remember like uh again i used it very long time ago uh and there we go so we have a repeating hello world how about that how about that so maybe we can try to develop something more complicated like a fibonacci sequence and whatnot uh let's define two variables the first one is going to be zero the first fibonacci number and the second one is going to be one the second one and uh let's say that while the first one is less than how much how how much we want to put there uh maybe one million one two three one two three right um we're going to print that a so i'm gonna assume that this printing method where you just like um how to say that put a string as a statement and it just printed it i would assume that it works like a printf right so uh i'm gonna just do d right and then maybe a new line in here and then uh just semicolon or something i wonder if i can just have i 64c where i would do a plus b right so this is a plus b and then b will be equal to a uh right so i think i think it has to be this the other way around a equal to b and b is going to be equal to c there we go and i wonder how can i remove uh like a whole line uh apparently i can't just remove the whole line so i will probably have to like learn how to use this text editor like off screen or something but i hope this is the code that will work so let's actually try to run it and it didn't like that uh because i forgot to actually provide the thing that i need to uh to run so let's actually put a in here can i run it and it kind of worked uh but yeah it didn't at the same time uh because i have no idea what the hell has happened right so i wonder what the has happened it only prints one and it loops forever oh boy uh so here's the zero here is the one here we do that until this thing is less than one million right then i try to print this thing uh all right and then c is equal a plus b which is going to be one right is going to be one uh then i assign a to b to a which will make a one uh and then i say b to c which is going to be one so then on the next iteration it should be fine uh right so it's kind of weird so i'm thinking maybe i should actually define this thing somewhere here right so maybe i have to predefine this entire stuff now it works oh my god we're off to a great start so if i define this variable in here this doesn't work for whatever freaking reason i have no idea why right so maybe it doesn't support like a scope defined variables or something like that that's fine but why did it compile then right and if i put this thing in here i 64c uh it works i mean that's fine i can just define all of my variables at the top of the program and just use that like i just it's simply unclear why it wouldn't work uh right so i mean i'm not gonna question the divine intellect right so it's definitely not a bug it is definitely not a bug it's probably a feature and there's probably a good divine reason behind that feature we just don't know with it yet because we don't have a divine intellect uh alright so yeah uh zero zero zero seven that's fast this is probably because i'm we're using kvm right and i would presume that through kvm it's going to be like running on a native speed maybe i'm not really sure but yeah so we enabled kvm for for qem so it should actually run pretty fast so that's pretty cool uh okay so i'm i'm super happy with what i see in here uh so maybe we should attempt to solve uh advent of code problem day one so i suppose we have everything because we can just run things so should we try it should we just go ahead and try a problem uh let's go ahead and do that that okay so here is the first problem i've never seen i've never read that problem before so i'm opening this problem for the first time i probably should log in with my like github account or something so this is going to be my first impression first row an edited impression of the problem so is it going to be difficult is it going to be hard i don't know but since it's the first problem it's supposed to be relatively easy right so they're not going to start with something super difficult uh hopefully i don't freaking know uh we'll see so day one sauna sweep you're minding your own business on a ship at sea when the overboard alarm goes off you rush to see if you can help apparently one of the elves tripped and accidentally sent the sleigh keys flying into the ocean so before you know it you're inside a submarine the elves keep ready for a situation like this okay it's covered in christmas lights because of course it is and it even has an experimental antenna that should be able to track the keys if you can boost its signal strength high enough there is a little meta that indicates that uh the antenna signal strength by this uh by displaying zero five stars okay uh oh okay so every time you solve a problem the the strength is increasing so okay uh your in your instincts tell you that in order to save christmas you will need to get all 50 stars by december 25th collect starts by solving puzzles two puzzles will be made available on each day in the advent calendar the second puzzle is unlocked when you complete the first each puzzle grants one star good luck so as the submarine drops below the surface of the ocean it automatically performs a solar sweep of the nearby sea floor on a small screen the solar sweep report your puzzle input appears okay on a small screen the sonos will report your puzzle input appears each line is a measurement of the seafloor depth as the sweep oh we'll have to put the file into the temple os i forgot about that so the the input is probably going to be huge so we won't be able to just like oh damn all right each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine for example suppose you had the following report right so we have this kind of this report indicates that scanning outwards for the submarine this centers we've found depth uh basically this depth right so it scans outwards okay and so on the first order of the business is to figure out how quickly the depth increases just so you know what you're dealing with you never know if the keys will get carried into uh deeper water by an ocean current or a fish or something to do this count the number of times a depth uh measurement increased from the previous measurement this is actually pretty surprised there is no measurement before the first measurement uh and in the example of all the changes are the following okay so this increased increase decreased okay in this example there are seven measurements that are larger than the previous measurement how many measurements are larger than the previous measurements this is actually pretty straightforward but if i take a look at the input it's probably freaking huge uh right so i won't be able to just type it in into my into my thingy so i'll have to i have to find a way to maybe mount the current hard drive and just like do something do something with that so yeah i'll have to figure it out [Music] it would be kind of cool if i could just download that but we don't have any uh internet access on the temple os unfortunately and i also have no idea how to read files from the tempo list but again so today's stream is just basically learning and setting up the development environment so that should be fine that should be fine uh okay so i'm gonna quickly close temple os and i'm gonna basically grab my file uh where is the where is this entire thing okay so let me actually bring it back in here and i'm gonna get my puzzle input so this entire thing sounds pretty pretty easy to do right [Music] so let me see so this is gonna be input txt right and i wonder where i wanna i'm gonna use easy because it's a little bit easier to do this way uh right so then i just do that and uh then i say this entire thing and then i just quit so input txt input txt so there we go cool uh winset uh vincent hoax thank you so much for tier one subscription thank you thank you thank you and welcome to our epic temple os club all right so the real question is uh can i just like take this piece of and mount uh that's the real question uh so it is a dos mbr boot sector petition so maybe we can just mount that thing can i go ahead and mount it all right so we create mnt and mount uh aoc 2021 mnt and uh do i have to do sudo because i'm mounting it to only user space right so maybe i can do that without the student only rook can do that okay so cool so uh okay so it says some that i cannot see wrongfest type bad option bad super block on dev loop zero missing code page or help program or other errors so everything's bad what an error message holy everything's wrong everything's wrong everything's bad no you can't do that no no bad bad error error holy that's very intense error okay so um temple uh temple os qema raw image i think we're using humor row image so and uh like mount maybe linux mount right linux mount let's see [Music] so mounting row or cue cow cube image but we don't have a cucao i think i didn't create uh specifically cucao right so maybe we'll have to create a cucao we'll see we'll see uh support supportcenter hpe.com that doesn't even load very cool very very cool go away uh next one how to mount a qma virtual disk image okay so let's say you discover critical business data in a legacy dos spreadsheet file and excel can't read the file if the legacy program originally run on dos you might boot a copy of free dose and install the legacy program there to extract the uh or export the data or to a common file format like a comma separated csv file you can follow our instructions to install and boot free dos using qma virtual machine okay you can mount a qma disk image using two basic methods using an offset to mount the image directly or using the lib guest leap guest fs tool package that sounds interesting so uh using an offset linux linux can mount qemu's raw image disk image raw disk image format assuming it knows where to find the start of the c drive this is very interesting partition on the virtual disk the virtual disk can contain multiple partitions but for most legacy operating system installations like dos you probably only have one partition this is the c drive let's look at the output from the linux fds command using the minus l option uh using the minus l option will list the partitions on the virtual disk okay so let's give it a try i suppose it's going to be disk f disk minus l aoc and it doesn't auto complete why it doesn't auto complete because i don't have a f disk okay i have no idea i think like it should be available on all of the installations and it's already installed thank you debian very cool and i know exactly what the is going on right because it's available in s-bin because it's supposed to be like the administrator level tool right so and it's put in as bin and it's only available when you do suda but outside of sudha it doesn't work and it's actually a very common theme in debian right i encountered a lot of problems because of this debian mentality and i've even seen a lot of like workarounds in like applications uh because of that mentality like it's a really weird decision but this is debian for you for whatever freaking reason so yeah so we have to do it like that i suppose can you can i just do that uh and it still doesn't have the complete property but at least it works like every disk doesn't have to be run at suda right so what if i have like a user level image that i want to run it on so yeah you have to do that explicitly um all right so what do we have in here um i wonder what is an offset though uh so here is uh some partition i suppose maybe this is the offset uh right so this could be the offset 63. uh okay uh cool here the c drive is the first and only partition on the on the virtual drive listed as image image 1. to determine the offset of the c drive you need to know the starting sector of that partition the output from fdisk shows this as 63 it's also 63 in our case maybe that's the offset okay so calculate the offset you also uh you also need to know the sector size the virtual disk image has sectors of uh 112 bytes right so do we do we know what the sector size um i'm not really sure so i suppose maybe uh yeah so sectors it's also it's it's the same essentially it's the same numbers actually you calculate the offset as the product of the offset and sector and there we go you have this thing um okay use the offset value to mount the virtual disk so i suppose we can just literally use the same thing at least try and see how it goes so we need to create a folder tmp dos and then mount loop offset uh blah blah blah t mp dos and then ls sounds doable sounds doable maybe we'll be able to do that okay so can i just like uh i already have a mentee mount to do o loop offset right i'm going to literally use the same offset we actually had two partitions in here as you can see but i'm going to just ignore that one and maybe try to mount that one later right so if the first one doesn't work we can try to mount that one uh so because in case of this one i don't have to do any work at all so should be fine and uh then what i need to do aoc and uh m t right so i'm mounting it to m t and of course you have to be uh root and it worked it didn't even complain what the holy i mounted i actually mounted this just worked so yeah so if you're interested in how to do that i'm going to put that in the description i suppose right so i have to put it in references okay how to mount the uh temple os uh disc i suppose right so yeah that was actually pretty useful and it doesn't didn't even require to do anything uh so that's pretty proud uh for everyone who's interested so this is a good tutorial right this is a good tutorial uh okay so let me see it has root access right so i'm not sure if we'll be able to just edit it manually but we'll see uh okay so here's the home and we have aoc uh aoc can i just create something like uh hello mom uh i cannot do that right so if i do sudo hello mom i managed to create hello mom and the real question here is when i go and um you know run the temple os i suppose i will have to maybe mount it first right uh so let's actually do it like this run dot sh and i'm gonna try to run it will it work that's the real question it kind of worked but i'm kind of scared to actually modify it can i like have it mounted and modified it from the virtual machine simultaneously that's the real question here so will it break a lot of because so far qemo doesn't complain so everything seems to be fine so let's give it a try so here is the idea maybe i have to put this thing i'm going to go into aoc and by the way the cool thing about temple os is that i can just click on the folders right i don't have to use the con and here we go we have a hello mom uh would you look at that uh just a second i need to ah oh boy uh okay so and then i have to do it like that there we go so we have a hello mom so let's actually try to edit hello mom uh not a text file that is very interesting i cannot just like edit it for whatever freaking reason maybe this is because it doesn't have an extension huh that could be the case okay so let me let me see what we can do about that uh so home aoc uh aoc 2021 and i'm gonna try to move hello mom to hello mom txt i'm gonna use the capital letters just in case uh right we're gonna do suda and i'm gonna go back uh and i'm gonna try to run that maybe it just wants a specific extension uh all right so let's do it like this and i'm gonna do a deer aoc aoc uh okay so it still has hello mom and can i click on that thing it still says not a text file which is a shame i think uh which is kinda oh it still opened it it just like threw a warning but it still opened it okay uh so now i'm gonna try to do the following thing i'm gonna say hello from god's temple right hello from god's temple how do you save everything uh i forgot how you save files in the text editor temple os editor save file very brief okay uh save save changes control c okay so we can just do control c i suppose all right you did save it hopefully so if i try to open it one more time will it be there uh no the text file okay and it's still there okay everything seems to be fine now i'm going to close this entire thing and i'm going to go into mnt uh all right so home advent of code and i'm gonna do cut hello txt there is nothing there so it didn't actually save anything it didn't actually save anything which is kind of such maybe uh this is because uh we have to unmount it first right so to make the changes visible i have a feeling that we have to unmount it first right uh all right so let's do umount mnt uh huh okay cool so if i take a look at m t right now so it's completely unmounted and let's run this into i think one more time uh to the to control c uh uh control s not c i'm russian uh in russian language c is the s letter and my brain actually confuses them i press ctrl s don't worry about it uh i just said ctrl c anyway so uh yeah russians confuse these letters all the time don't worry about it so but i pressed the right one i do remember that okay so here's the hello txt and okay now it is working uh hello world and i'm gonna press ctrl s i'm pressing ctrl s hopefully right and if i try to open it one more time it is there okay pressing ctrl s and uh now i'm going to do it like this okay so i need to mount it one more time uh probably want to actually save this command uh somewhere right so i do do i want to save sudo as well yeah i'm going to save suda as well uh let's create mount sh right so mount s this is not what i wanted to copy actually uh all right so uh i want you to copy this thing uh and bin sh set xe all right cool oh it would be also kind of cool to uh to have a script that also installs and creates this image right so we have a script that installs and create the image we're gonna have a script that runs the machine and we have a script that mounts the hard drive so we can put something in there and i might as well actually share all of these scripts uh you know public you know gitlab or github or whatever right so yeah i think yeah so we have something to share today that's actually pretty cool uh all right uh chmod plus mount mount sh right and i'm gonna just try to do mount and it mounted the thing um right and i'm gonna go into the mount uh so home aoc aoc hello mom and if i take a look at hello mount there we go hello world and at the end we have e whatever is that supposed to mean it's maybe some sort of like a special ending for uh for temple os i don't know so no end lines though that's kind of weird add unmount mnt on star that's actually a good idea [Music] forcing e um all right so at least we can exchange information between the uh between the virtual machines and stuff like that okay so i'm going to try to copy um input right where is the input do i have the input um so here is the input and i'm going to copy it in here right so it's going to be suda and we've got the we've got the input all right and you mount m t but i'm gonna do you mount automatically maybe a little bit later okay so if i do ls uh m t right so we'll get that and if we're gonna try to run this thing and let's go ahead and do that all right take a tour no uh i'm gonna cd um let me just do that i'm gonna use the mouse we're in 2021 uh and if i try to edit the input txt uh what we're gonna have in here not a text file are you sure about that buddy okay so here is the input from the website so we got the input from the website into the into the system that's pretty cool i wonder if i can uh rename the entire thing so there should be some sort of a command that called that is called mv or maybe move okay there is a move command so and let me see uh it takes move file from one location to another or rename uh that's actually a pretty cool implementation look at that look at that it just copies and delete the previous one so though on operating systems like linux moving is faster than copying because i presume because of the file system right the only thing it changes it just changes the inode information right and that's why moving is usually like instantaneous within the single file system but here if you have a huge file uh to move file from one location to another one it's going to literally copy it by by byte but i'm not sure it depends on how copy is implemented it's actually a very interesting question so and if i do copy right so here's the copy i can try to look into the copy all right and copy is uh all right so yeah it copies stuff it copies chunks and stuff like that i suppose right copy file if the name ends uh in z it will be stored compressed if not dot z it will be stored uncompressed um i really like how self explorable temple os is right i have a command i cannot only look up the documentation of the command i can see the implementation of the command how cool is that it's like it's almost like using emacs it's like if emacs was an actual operating system like an actual kernel and instead of uh elise you had a holy see that's actually so cool i really like these self-explored systems right where you can just like take take it apart and see how it works and stuff like that it's really really cool um all right so uh what i want you to do i want you to actually move uh input um right so this is move input txt and i just wanted to move it to uh input txt capital thingy right so if i take take a look at this now right uh i should be able to just open it and it doesn't complain about not being text okay that is very cool um so the next thing i want to do i want to be able to like open a file and read from a file the question is how do you do that in holy see this is something that we'll have to learn um so terry was a great guy his mental condition got to him yeah so it's actually really really freaking sad he's a genius but yeah so and again i just i just want to mention if you consider if you're thinking to donate me to support me this month instead of donating to me consider supporting the charities that are listed in the temple s website uh right so if you go to the to the official website of temple s at the bottom of the temple os um right there is a couple of charities in here so i really recommend to donate there instead um all right so let me see so luckily there is a lot of information out there there is like a community around the separating system so we can try to google up how to read file uh holy uh c read file can we find any useful information on that uh x86 xd for linux assembly reading files uh the language bar says holy c setup i'd love to see if we support it to linux function prototype complete uh conquer dance uh call this holy scriptures okay so that's that's kind of it's kind of interesting uh all right so let me let me think so some of the things we can do actually we can try to guess how the functions are called right so i suppose maybe the function is called open right open file or maybe file open right no they're not called like that uh so there's a file there's a file of write and file read right but i suppose they accept oh that's actually super cool read the whole file from disk this is not bad maybe that's what i need so it just allows me to read the whole file from from this can returns it as a string and the question is does it is it new terminated or something like that um yeah we can just do that and we can just parse it myself um that'll be actually kind of cool so um so file writes file read so yeah let me see uh is there any functions for working with strings string str strllen ester copy strcmp uh strc hr maybe something like strc hr there's no such thing so maybe some of the string functions i'll have to like actually write myself but anyway so uh let's go ahead and create a file day one right so ed day zero one hc uh right i'm gonna open the first day and uh one of the things i want to try to do i want to maybe um file read right i'm reading the file and the file that i want to read i want to read input txt right so this is the input txt file i suppose it doesn't accept anything else right everything else here is optional so we have size in here uh oh it will return you the size of the okay this is something that we actually want right so you can read the file and it will also return you the size of that file uh jag fellow i hope you're pronouncing the nickname correctly thank you so much for which prime submission thank you thank you thank you and welcome to our epic temple club so yeah somebody on on youtube asked me a very good question how many epic clubs do i have i have a lot of them actually uh so all right let me let me see what we've got uh so i'm definitely gonna spend some time getting used to this operating system off-screen right so i'm gonna maybe uh go through more tutorials and stuff like that uh because i wanna get comfortable because i'm gonna be developing it for the entire month so it's not particularly convenient so it will return the size it will turn the attributes and stuff like that uh okay so size is i-64 right i-64 size we're gonna put it in here so and i'm gonna provide it in here so here's the size and we're gonna print something like uh size of input txt input txt is uh i suppose i can just put d in here and i hope it will just work but i'm not hundred percent sure so let's actually do f5 and it couldn't do that file not found input txt okay so it couldn't find that file for whatever reason even though it's right there so maybe i have to put like a dot slash or something to be able to actually read this entire thing uh wait a second wait so just ah dear like this so this is a day one uh day one uh and let me try so i suppose it is very important to do something like this okay file not found uh so is it backslashes i think it's forward slashes right um so add whole path i do i really have to is there like a relative path in there in there um so it's kind of i can try i mean sure c slash uh home uh right so but i'm not sure ctrl s and i'm gonna do it like that so home oh it is running in yeah i see i see what's going on that's really weird why would it why would it run in home though um i mean i can just copy the input txt to home uh right so can i just do something like this uh okay so we'll copy it in there and if i do deer like this we do have the txt file in there if i open it like that and if i do f5 it actually worked so when it says the input of txt is this and then i forgot to put uh a new line in there so i think i have to put a new line in here so i do this size of this thing is basically nine kilobytes so it managed to read the whole thing uh thank you so much 8 for tier 1 subscription thank you thank you thank you uh what i'm thinking is that like is there like built-in features built-in things for parsing files or do i have to implement everything myself uh i don't mind implementing everything myself but it would be kind of cool if there was something uh so i can try to see scan f scan uh so there's a scan character scan key or some stuff like that so it's not what i think it is right bars so there's the str okay the cool thing here is that we can try to go into these functions and it will lead us to a file right so this it's a part of the kernel um it will lead us to a file that contains other related functions so we have str len um string length and i suppose it's like null terminated so it's not what i think it is um so read the ports so there's a swap a maximum and stuff like that so there's a lot of like useful functions and whatnot so one of the okay i can parse it myself but i need a function that converts a string to an integer can i do a to i uh a to maybe s to i so i just don't know how terry would call that str to okay so i'm gonna just assume that it just doesn't exist so all right uh str2 okay thank you thank you so much str uh to i 64. okay that's actually perfect so and the question is what does it accept uh it accept probably new terminated thing oh it acts okay it acts like str2d uh right so it even has an end pointer and whatnot all right so i i do know what the is going on in here this is actually super convenient so we can try to use that right so we we read the whole file into the buffer right then uh we can just use this function to constantly read the next uh the next number right we constantly read the next number and uh we advance until we reach the end or something like that so yep i think that's a good idea uh though it's kind of sad that file read doesn't put like a new line at the end but i don't know [Music] all right so you know what i think i want to make a small break because i've been programming for i've been setting this entire thing up for how much for entire hours so let's actually make a small break and after the break we're going to try to parse that file and once we manage to parse that file we will try to solve the problem right so the only thing we need to do we need to get that data into the holy scene what am i drinking i'm drinking earl a gay tea okay let's make a small break and right so let's go ahead and try to parse the entire file and see how it goes uh so file read will return the string i suppose this string is returned like this can i just extend the intel i can actually do that that's actually pretty cool uh so this is gonna be str right so here is the str uh and i wish i could just like um delete the lines somehow but i don't remember so there was like a cheat sheet for the editor somewhere uh so this is how you do that cheat sheet [Music] uh temple s editor uh cheat sheet any cheaters in the chat forcing cd uh all right so i don't know i don't know maybe i'll just have to go through the tutorial one more time but i don't want to spend time on that um all right so i suppose uh str to i-64 right so it accepts also end point and we need to keep doing this thing until we reach the end of this entire stuff all right until we reach the end of this entire step but that is really tricky uh that is really tricky so how does it determine the end uh right so while true uh if we encounter that that and that uh uh-huh so just wanna see if it tries to identify like uh zero or new terminator of some sort a continue so it's one of those i don't see the null terminator though [Music] white spaces okay it removes the white spaces and whatnot so it's going to be minus this is this and zero and if it's something else you do that uh if right exact um oh maybe it doesn't even need to do the zero thing it doesn't even need to do that because it stops and at any non-digit or something that doesn't fit into the definition of the number it doesn't even need to check for normal termination okay that makes sense i don't know why i brain farted so much in this uh so an anonymous user gifted a tear once up to terry a david's temple thank you so much and anonymous user for gifting us up to terry davis as far as i know it's an account that actually like streams the archive of terry uh developing temple os right i think so yeah thank you so much for for gifting this up uh right i think it's an official one even or something depends on the definition of official in that particular case so yeah thank you thank you so much uh all right so and i suppose the input txt actually also ends with the new line hopefully right it should end with a new line and that is how we're gonna know that uh we reach the end right so um all right um that makes sense kind of makes sense uh so i 64. so we provide the str then i provide the radix and then i need to provide the pointer to the ends right so we need to keep track of the end uh u8 this is the end and that's the pointer to the end so and seems to be a key word so maybe i'm not allowed to use that as just in case i'm going to put end p in here and i'm going to use np in here so i'm not gonna initialize this thing okay cool so str uh is gonna do that and now i need to establish uh i need to establish the um the loop right up until what point i'm going to loop that is very very interesting question up until what point uh because um so we sort of like advance this thing end point becomes a new stuff so we can do something like while size is greater than zero right while size is greater than zero uh we're going to try to do that and i'm going to just assign it to x and x is i-64 right so this is basically the x right and then and we can take the end p and subtract the string and that essentially gives us how much of the characters how many characters we consumed which we can quite easily subtract from the size right so yeah and that's how we update the loop and hopefully that will work maybe uh so there will be some problems uh with like and um the the new lines and stuff like that but maybe we can just adjust this condition maybe up until uh size is greater than one uh if it becomes one we know that only one new line left so yeah maybe that's going to be the case so and on each thing i'm going to just print that number right so i'm going to just do uh d new line x and hopefully this is a sufficient uh sufficient program to actually parse everything so let's try to run this thing and it didn't work and well at least it parsed the first character right it parsed the first character uh and uh let me see what we can do about that i forgot to assign end point to the str so s end pointer is the new str uh str equal and p so and this is how we're gonna actually do this entire thing and we parsed all the numbers i suppose so uh some of them became like zero or something right you see i think this is precisely the problem i was talking about right it's the problem of the last uh character so i think we can try to solve that by basically uh rising it to one and if i try to run it one more time there we go we don't have any extra characters so the last one was 83 41. let me actually confirm that it's 83 41 okay so that's fine uh i think we managed to parse all the characters believe it or not that was actually pretty easy and it's kind of cool that they can just read the whole file into the memory and that's it i wonder if i have to free this entire thing um because maybe every time i run this program it leaks a little bit of memory but we're in 2021 just buy more ram okay let it leak let it leak let it leak or let it leak memory costs nothing let it leak okay so i think uh according to the definition of the problem we don't even have to um store that array right so we can just like store the previous value right we just need to store the previous value and we need to count how many times like uh this thing increased [Music] all righty let's go ahead and do that i'm a little bit nervous i'm a little bit nervous i can actually take a look at the implementation of file reads maybe there's something said there about memory stuff this window is really annoying and i have a constant urge to close it but at the same time it is extremely useful because it shows out the completion and i'm just afraid that if i close it i won't know how to bring it back so it is really really scary like i hate this window but at the same time it provides the usual information so i'm just going to keep it in here and just like suffer uh so anyway so does it allocate any memory all right so it uses like free free um so if there is a function free okay here is the malloc here is the malloc uh-huh so this is the res and what it returns uh it returns the rest which it actually mallocked uh defense subscribed with uh tier 1 subscription for 15 months thank you thank you so much and welcome to our epic temple s club okay so it uses malloc right it uses malloc and malloc just allocates some stuff right and then you have to freeze so according to my understanding according to my limited understanding uh we probably have to do free str but the problem here is that we lost str right we kind of lost it so i think i'm going to actually create like a separate variable this is going to be start okay maybe i'm going to call it begin instead begin okay so that's fine and then i'm going to just assign you str to begin and uh then i'm gonna do the parsing right so i'm doing the parsing and then i'm gonna free free the begin right okay so that way we're not gonna leak any precious memory to be fair i just realized that we are in a virtual machine right we are in virtual machine that means we probably want to free the memory right alt w will open out the complete window okay so thank you thank you so much so if i try to do the ah debated by the chat and it didn't do anything it it doesn't open the autocomplete window you literally just debated me i should not listen to the chat chat debated yet again it doesn't bring it back it doesn't bring it back anyway so you know what you have to do in this particular case you know what you have to do in this particular case you reside in the whole operating system never listening to chat ever again uh that's for sure so let's not take the tour uh and uh let me take a look uh this thing and a-o-c-a-o-c-e-c uh day one we didn't lose uh anything so i'm gonna f5 and everything's fine at least nothing crashed well to be fair if something crashes within temple os your entire operating system crashes so you would know right so that's that's fine uh okay so we need to um probably define some sort of a counter right so this is gonna be the answer uh right so this is the answer and i really don't like that ants is already taken uh 0x grand 27 um gift donated i suppose 100 beats thank you so much for 100 bits i really appreciate that so this is the answer and this is initially going to be uh also what i want to do i want to store a previous value right we're going to have i-64 and we're going to store the previous one but here's an interesting thing at first we don't have a previous value so i think we're going to indicate the lack of a previous value as -1 so this is going to be like a negative saying that there is no previous value or anything like that uh okay so and here instead of printing this entire thing what we're going to do uh what we're gonna do if previous is greater or equal than zero and x um okay so x is greater uh than the previous right then we're going to uh take the answer and increment that answer right and after that uh after that i'm gonna assign uh x to the previous right so i parsed this entire thing uh then i basically analyzed it and then i advanced the the rest of the stuff so after that i should be able to print the answer so let's go it can be zero d and uh answer uh there we go if i try to run this entire thing it's 1581. is that a correct answer is that a correct answer i don't know i have no idea 1581 first try how about that freaking first try cool uh so yeah we actually did it i didn't expect that holy that's cool so let's take a look at the part two um part two electric boogaloo oh boy this already sounds like fun considering every single measurement isn't as useful as you expected there is just too much noise in the data instead consider the sums of a three measurement sliding window again considering the above example a a b a b c a b c d and uh okay so it also like rolls around or something so three measurement window okay step by comparing the first and second three measurement window ooh start by comparing the first and second three measurement window the measurement in the first window are marked a uh 2028 their sum is six kind in a seven the second window is 20 28 20 uh huh the sum of the measurement in the second one is larger than the sum not the first so the first comparison increased your goal now is to count the number of times the sum of the measurements in this sliding window increases from the previous sum so compare a with b then compare b with c then c with d and so on stop when there aren't enough measurements left to create a new three measurement window so basically we have a rolling window of three elements and we just like go and see if something increases or not uh the sum of each measurement window is as full okay in the example the five sums that are larger than the previous sum blah blah blah how many sums are larger than the previous sum looks reasonable um [Music] so 19 then 20 28 10 uh huh so i i do understand what this text is saying i do understand it i don't understand these graphics the is going on in here like seriously like yeah what okay uh a b uh abc so how does that correspond to whatever is written in here um all right and then this basically removes that and all right ac like why is it written in such a weird way so what this is so weird like like it doesn't even explain this explains it but this doesn't it doesn't make any sense it shows the position of each window it shows the position of each window where position where it's bizarre this is the most bizarre graphic i've ever seen okay so anyway let's actually try to code that uh all right so what do we have in here i suppose we need to do the same process right so but we have to just have a different thing in here so what i'm thinking is that i'm gonna wrap this entire stuff into uh its own function uh u0 and this is gonna be basically part one uh right so i'm gonna just rub this entire thing into part one there we go and i'm not gonna actually call this part one [Music] right if i try to run this thing uh it doesn't do anything that's cool but if i do part one like so i don't even have to provide the parentheses right so it it prints the answer in here uh might as well actually maybe do something like uh part one and just print it like that and does it work yes it does in fact work so now i should be able to do something like this uh comment it out and do part two electric boogaloo uh u zero uh part two right i'm going to do it like that so i literally need the same process pretty much [Music] so now uh can i just copy paste this entire thing uh i should be able to so the reason why my code looks like is not because i'm a bad programmer i mean i'm a bad programmer but that's not the reason the reason is because i don't know how to use this text editor i wish there was like a way to how to indent everything but i don't want to go for each individual line so that's why i just don't indent this entire thing i'm going to try to press ctrl c and then ctrl v and it copy paste the whole thing okay that's actually pretty cool so uh all right so we have something like previous in here and so on and so forth [Music] so maybe we want to kind of like a predefined window right so when we're starting with this thing right when we're starting with this thing we need to do like um three iterations to build up the window if you know what i'm talking about right uh so that's what we need to do that's what we need to do oh by the way can i just do like this where i press ctrl x and then uh just put it like that okay so i can move lines around that exactly that is actually pretty convenient so i really like that uh so here we have we basically take the next value and we update the state and here we evaluate the value so essentially what i want to do i want to predefine the rolling sum window right so i'm going to define the following variable i64 sum and initially it's gonna be zero uh all right might as well just put it somewhere here okay so once i discovered how to move lines around it actually became way more simple to work with like holy right because quite often when i work when i edit in vim or emacs i think in terms of moving lines around rather than characters and i really really miss that feature so now what i do is essentially i just select a particular section and just control x and control v so like in the classical editor it almost works like a classical editor which is really convenient uh all right so what i want to do i want to perform like three iterations uh right i want to perform three iterations but the question is how can i easily do that i need to allocate another variable something like i 64 i zero and for i equals zero less than 3 plus plus i i essentially need to repeat this thing and add the result to the um to the sum right so that's what i need to do in here uh so here's the x and i'm just gonna be adding this thing to the sum there we go okay that's cool that is very very cool so we don't really need i after that but that's fine so here we continue we read the next x and now i need to essentially um come up with the with the next sum right so i need a variable for the next sum so i-64 next sum right so this is the next sum uh and next sum is essentially the current sum minus the previous value basically by previous value i'm gonna i'm gonna call the element at the beginning of the window right so the beginning of the window and i'm gonna add x so that acts like the next uh you know the next summon here and that acts like the next sum and in here now uh if uh fabulous flow yes it is thank you so much for two months of twitch prime subscription thank you thank you thank you and welcome to epic divine club uh all right so what we're gonna do so this is gonna be if the next sum if the next sum is greater oh this is not particularly convenient right so maybe i have to actually keep track of all the three elements right [Music] i didn't consider that so maybe yeah i was hoping that i can just yeah i need to keep track of all of the three elements unfortunately all right let's go ahead and do that i mean it's just not that difficult to do uh right so we can have something like a b c and d for the next like fourth element if you know what i'm talking about right so and in here uh i'm gonna just have i'm gonna repeat the same code three times uh right i'm going to repeat the same chord three times so first for the uh a right we don't really need this thing anymore right uh so i wonder if i can just like do something like this cool so this is going to be first for the a then we're going to have b then oh what the has happened okay then c and we don't not gonna do any d right we're not gonna do any d so and in here uh when i search for the next one i'm gonna just assign it to d and the current sum is going to be abc and the next one is going to be bcd right so uh and essentially i can actually quite easily check all of them uh so if the next sum b plus c plus d right b plus c plus d is greater than a plus b plus c i increase the answer right and then i basically uh you know reassign everything uh accordingly so a becomes b b uh becomes c and c becomes d right so this is the simplest code i can come up with actually so and then we don't really need x anymore uh right so here is the size of the whole thing uh then the the parsing state then the answer we don't even need previous right we don't keep track of the previous we don't need these things the only things we need is abcd right so and that's basically the rolling window in here um and then we increment the answer and this one is going to be just basically part two and i wonder if it's going to work i'm actually a little bit concerned whether it's going to work maybe i want to test that on the um on the sample data right let's actually try to compile this entire thing and it kind of worked it printed 16 18 but i'm not sure if that's the correct answer i'm really not sure if that's the correct answer i would rather test that on the sample data so let's actually take the sample data and in this case we have like five uh right so uh let's go ahead and just quit the operating system right uh super quick and i'm gonna mount this entire stuff right i'm gonna mount it and i'm gonna go inside gotcha hyper so this is home uh here's the input and i'm gonna do ed i probably wanna do a pseudo right so ed sample txt uh right so and what i'm gonna put in there oh boy i probably have to prepare this data first so let me copy paste that to uh to my trusty emacs uh there we go i'm gonna remove that and here we have a new line all right so i'm copy pasting uh one more time one more time and then i press this and then i save this entire thing and then i quit this entire thing so and in sample txt i have everything in here and i hope i do have the last new line in here okay so i do have last new line it's kind of important to have this uh have this last new line for the parsing right okay so uh let me now unmount uh you mount your mount mnt sudo there we go so everything seems to be okay lsmt and i'm gonna run the uh data operating system okay okay so let me see do we have the sample thinking so here is the sample and if i take a look inside of it here is the data right so that's the data from the website so it's really actually kind of cool that i can exchange the data between the host operating system and the guest one i really like that uh okay so let's go into aoc 2021 and day one uh okay guys so i'm going to extend the window uh all right so sample sample i'm going to press f5 so there is a five of them and according to the official data it's a five sums okay on the sample data in fact it works everything works on the sample data the question is does it really work correctly on the actual input data right on the actual input data it's 16 18. so let's try to submit that right i have no reason to not believe that this could be the case let's put 16-18 we solved the first day in temple s from scratch let's go alright so yeah we did so i i really need to spend some time actually learning the operating system and learning the editor because that was difficult that was painful so i also need to learn how to search for different examples and stuff like that i'm going to spend some time uh off screen like going through these tutorials and stuff like that because it's probably not that interesting to watch right and then maybe the next day the next day we uh the entire process is gonna be more uh like more efficient and whatnot so i also wanna publish all of these scripts uh you know um to the gitlab or something but i need to think how i wanna organize them right so i wanna script that installs everything and prepares everything we have script that runs everything and also scripts that mounts everything so uh yeah i'm gonna put the link to this source code in the description but the source code is not prepared yet right source code uh and i'm gonna put tbd in here just to remind myself that i need to do that uh all right so that was pretty pog not gonna lie and we already spent like almost two hours doing that so we're pretty on time right so because i usually to do two hour stream all right i guess that's it for today that was actually very cool thanks everyone who's watching me right now i really appreciate that thank you for all of the subscriptions and donations and stuff like that i especially appreciate that and i see you all the next time i'm not sure if i'm gonna stream every uh every day so maybe some of the days i'm gonna do uh off screen because sometimes i need a time off from streaming because it's actually kind of intensive so maybe the next day maybe tomorrow i'm not gonna stream and tomorrow's day is gonna be basically offline i'm gonna just record myself doing that and then publish it on youtube uh right so if you're watching it live um here is the uh youtube channel where i publish uh all of my recordings so sometimes i do offline sessions where i don't stream i just record like offline so maybe the second day is going to be that all right so thanks everyone for watching and let's maybe rate somebody is anyone doing advent of code right now on a science it's not a science and technology it's a software development section of twitch uh all righty thanks everyone that was actually super fun i really enjoyed that holy mine got kicked route so let's wait uh maybe i should stop the temple os maybe it actually hooks the entire machine so provo uh property streaming so is he streaming like some software development i'm okay he's doing like a vulcan ray tracing okay so provod is actually a very cool uh computer graphics developer computer graphics hacker and what he's currently doing he's actually adding ray tracing support for an open source half-life one engine using vulcan okay so that's how cool he is so we're gonna read him uh so i'm gonna do rate robot he usually streams in russian but he also speaks english so if he speaks in that weird clay gone language just ask him to please speak english and he will answer you in english all right so let's let's start the rate get ready for the rate boys and girls get ready for the raid and i see you all and next time love you
Info
Channel: Tsoding Daily
Views: 22,030
Rating: undefined out of 5
Keywords: templeos, holyc, advent of code, 2021, terry davis, competitive programming
Id: nvldfkikveI
Channel Id: undefined
Length: 105min 57sec (6357 seconds)
Published: Thu Dec 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.