Coding Puzzles - HR Machine - Episode 1
Description
Learning coding skills by completing logic puzzles in the steam game "Human Resource Machine"
Transcript
Today we're playing a game called human resource machine this teaches basic coding Concepts without having to actually use real code I haven't tried it before so let's see how it goes okay create a new file take a picture level one mail room looks like I write code on the right side of the screen and I've got three boxes I'm trying to put into from the input to the output so I'll grab one inbox one out box and hit run I guess oh so it only grab one box so I guess I need reset I guess I'll do it three times so in real code I'd probably write some kind of loop but it probably doesn't teach me that complicated of Concepts yet okay looks like it's working that was easy let's try the next level okay it looks like basically the same thing as before except now I got a whole bunch of letters oh okay so the jump command uh in like a basic language this would be called go to and you'd have a line number and so this is essentially the basics of a loop so like I could grab inbox output out box and then jump back to the inbox then it's just going to keep looping uh I think this should work as long as there's an infinite number of items in the inbox but before it had to be an exactly three and so if it's not infinite on the left side then at some point it Should Crash because I should run out of boxes but yet I'm still trying to carry them back and forth but I'm assuming they don't want to get that complicated yet if there was a certain number I'd have to do some kind of if statement to tell everyone to stop okay definitely not infinite oh it looks like I'm good I can go faster that's nice okay even though it wasn't infinite it still just good so in real code that would be an infinite Loop and your program would never stop but I guess they're simplifying it which is fine still teaches the concept Next Level copy floor I don't exactly know what it's telling me to do it wants me to spell the letter bug in the output so I need to grab this number four first but it told me to ignore the inbox because these numbers negative 99 I don't know how that's helpful so I mean obviously I need to put the B into the outbox but I need to tell it how to grab that B I'm assuming it's this copy from command because that is a new Commander gave me okay yeah so it has a parameter so copy from is basically a function and it's asking me which parameter so I can select B for bug and I would have thought I could type in the number four but I had to just drag but that's fine okay so I'm saying grab the B put in the outbox grab the U put it in the out box grab the G in the outbox should work I'll fast forward it maybe I shouldn't fast forward it I lose the excitement of watching it happen all right Next Level Scrambler Handler oh I guess the conveyor belt was broken and that's why I couldn't use the last time okay so it's kind of like putting it on the floor as like a temporary variable and it wants me to put everything in reverse order so this is actually a little bit more tricky to think about um it it only works because there's exactly six items on the left and three spots on the floor so I think basically I'm just gonna grab the first three items to come on the floor and then okay this makes more sense it says I'm only grabbing two items at a time and reversing them um okay so I'm gonna grab the inbox but instead of putting on the outbox I'm going to copy it I guess it doesn't really matter where I put it um so that's going to put the three onto this first square and then it I'm assuming because I grabbed it off the inbox it's no longer going to be there so next I'll grab the number eight and copy it to the one square and then the third letter oh actually I can just put the next one directly on the outbox because I'm only reversing two at a time so I'll just grab the next one also have a copy from okay so the copy from can only grab it from the floor not from the side so that's not gonna help me let me remove that oops I did not mean to clear the whole thing all right uh inbox copy to square one then inbox goes to outbox then what's confusing to me is I don't exactly know when I say something goes to the outbox where does that go from but I'm assuming it's whatever I picked up last so because I'm copying from this square that I copied so I I think when I grab from the inbox copy to the first Square I'm assuming it's actually even though it says copy I think it's actually moving it I hope so because I don't want it to stay on the on the conveyor belt and so that allows me to grab the second item which is eight and then that goes immediately to that box bucks and then I grab what's on the floor that I copied earlier and because I grabbed it I'm hoping that's what goes to the outblock so in the end because I want to keep repeating this process I'm going to put a jump at the bottom but let me just test it to see if it works how I think okay yeah exactly so even though he copied it he threw the original one away so yeah that looks right now I just need to put a jump on here and like I mentioned before there should be a condition in a real programming language there should be a condition that tells it to stop after it runs out of items but it seems to just do that automatically okay and then even though when I copied from it left it on the floor whereas before it actually removed it from the conveyor belt when it put a new item on that spot it deleted it okay looks like I passed it next level drinking some coffee wait is this actually a task or just like a video I know I skipped this okay yeah that was not a real task it just told me that we're running out of power okay so now it wants me to instead of reversing the order of the first two items it wants me to add them together so instead of one and one going to that box it wants the number two to go to the outbox so I guess I'll grab the first inbox well let's first check with this new ad command what the parameters are so it only lets me pick one parameter so I'm guessing whatever I'm holding in my hand gets added to wherever I tell it I'm adding to so I'll grab one item from the inbox I'm hoping if I add it to the first Square even though the first square is empty it'll still add if not I'll have to do a copy then I'll grab the second one do the same addition to that square and then afterwards I need to put it on the out box and I'm hoping it automatically whichever thing I added last is what gets put on the outbox but otherwise if not I'll have to copy from that square wear before I put on that box so let's just see what happens okay so it won't let me add if I have an empty value so first I gotta copy that value to the zero Square which means I don't need to add any more um so let's try again I'm guessing when it gets to the outbox it's gonna say that I didn't grab the value oh it oh yeah it did so um it did automatically um take the added value and put it to the outbox so that works great the only issue is I have to think about how many items are on the left side here because I only have three squares to work with and um I don't see a value too clear so after I added it it's going to be the number six which I put on the out well before it was six I think now it says seven and four maybe these numbers are randomized so seven and four added together it's going to be 11 I think then it's going to put that into the outbox the original Seven is still on the ground uh so for me to add zero and five together I need to use the second Square because I don't see any ability to erase this first square but then I'll do the same thing with negative six and one onto the third square and then I have nowhere to do the 8 and negative five so that is a little strange um now I could fake it if I if I analyze the numbers ahead of time I for example here I can see a zero I could just copy that zero onto a floor to reset it the problem with that is if these numbers on the left side are randomized it's not going to work so let me I also it might be interesting to try this debug sometime but I don't think I need it yet so I'll clear this the first number I gave me was seven so yeah now it's nine and two which is 11. so maybe the program doesn't actually have to be generic to where it works with any random input maybe it just has to work for the one task at hand um because otherwise oh this is a help so if I put jump down here it gives me instruction interesting so the problem is I don't know how to clear out a value and I've got more than three pairs of numbers and there's no way to it's like I could clear it out by adding a negative number so if I add nine and two together put on the Square I could then add a negative 9 and a negative 2 is clear out it sounds a little tricky I don't know if copy from and copy two clear it out I don't think they do something odd about the add command is it didn't I would have I would have expected after added for it to actually put it on the floor but it didn't so like the number 11 did not get put shouldn't get I would expect to get put on the floor but the last time I ran it didn't it just immediately put it to the app lock so maybe after the ad I need to do some kind of copy oh I guess maybe I can just replace the old number so I don't have to clear it out I can just replace the old one so for example I grab the first item copy it to square zero grab the second and add it here and then put in the outbox right then if I I really just have to do a jump because uh that should have been obvious so what's gonna happen is the next time it's gonna grab something off the inbox conveyor belt is going to copy it to that same spot the copy is going to replace the original value and then it's going to add the next number so this should actually work so 7 it should add the nine to get I think 16 puts it on the curable and it's going to put the sick and replace the seven and then add them to get 13. okay this should work let's pick it up so it worked I was really overthinking that one it actually was really simple okay it looks like I have a choice which direction I want to go I'm kind of feeling well there's quite a few levels to go I think I'm feeling the one on the left just because it ends quicker okay it sounds like it's saying this is like a challenge level supposed to be harder free thing in the inbox triple it and I'll box the result okay so I'm gonna take this first thing of seven basically times it by three and then put in the outbound so I could add it to itself three times that should work um so I guess first I grab it from the Inbox and that's gonna permanently destroy it until I put it like the original value is going to get destroyed but it's going to I can put it to this first spot so then in order to add I have to pick something else up to add it but I really want to add it to itself so before I do the ad I think I want to copy from that spot and I don't think I actually need to use the second and third Square on the floor because when I copy from I think it just makes a copy in my hand and then when I add it also just makes a copy in my hand um but I'm not ready to put on the outbox yet until I've added it a third time oh yeah so I just then I just add again so I first moved the seven because you can't do the add off of the conveyor belt you have to do it off the floor so I'm going to grab it put it on the floor then I'm gonna put it back in my hand because I can only add whatever's in my hand to whatever's on the floor um and so then once I've made a copy in my hand I'll just add twice to my hands so that should give me the tripled value then I'm going to Output it and then I'm just going to jump back to the top because I have to do it for the negative four four zero uh the only one that I'm wondering about is the command add is a little bit weird when you think about a negative four because multiplying that by three I guess it works because it should be a negative 12 and I guess adding negative 4 to negative 4 is actually negative eight so I think it should work nice at least that one worked so yeah it replaces the seven speed it up I think I got it okay so it's saying that I could have optimized this by using fewer commands and fewer steps so I think if I used one fewer command it would automatically use fewer steps okay let me just see if I could remove one command it says I only need six um I'm wondering if maybe I don't need this copy from because maybe uh before I was assuming that it always drops something out of its hand after it puts it on the floor but I maybe it's only throwing it out of his hand if it needs to pick something else up so if I just get rid of this coffee from then when I copy it to the floor I should still have it in my hand and so then I can just add two times yep okay so I was I was confused before about what caused it to throw it out of its hand okay it worked and that should solve the puzzle with the actual six command Challenge and that's a good point even in real coding there are different ways to code the same task that maybe both work but one's faster or slower than the other I'll do the next challenge those are seem like a little more tricky okay so it wants me to multiply by eight this time but it's telling me to avoid using too many ad commands it's like the obvious answer would be identical to the last one where I just take the value copy it to the square zero and then add it like seven times right um but it wants me to only use three ad commands but I suppose to times it by so and it's interesting it gave me more floor space normally I only have three and now it gave me five and it looks like I only have four but because the first one starts at zero I actually have five yeah that's pretty common for computers to count by zeros instead of one so I think the way I could reduce the number of ads would be each time I do an ad I'm uh it's kind of like I'm doubling it as long as I uh so seven plus seven is going to be 14 right instead of adding seven a second time if I then take 14 and add it by 14 then I'm doubling it again so to multiply by eight um well let's do the math seven times a I'm gonna pull up the calculator I don't think it's recording my calculator but that's the number 56. so if I take 14 plus 14 that would be 28 if I take 28 plus 28 that would be 56. so the first time I double it it goes from 7 to 14 the second time is 14 to 28 and then the third time is 28 to 56. so I think that would only be three ad commands so let's see copy it and then add it then I'm gonna I think it's when I add it it's in my hand so then I'm going to copy the added value to the second Square then I'm going to add the second Square so this first value will have seven the second one will have 14 and then I want to put the 14 and the third square at that I think that gives me the final answer so I put that in the out box and then jump back to the beginning to their items in the conveyor belt let's see what happens 14 28 56. yeah it looks like it worked I'll speed it up so even though this is the correct answer and something I like about this so far is each level is building on the previous concept and so if I'm able to understand the previous concept then I can do the next one fairly easily because I'm just adding one little like one little step but one thing that's a little silly about this particular challenge is even though it got me to use fewer ad commands it made me do extra copy commands so as far as the actual speed of the program I think it would be the same so I don't see the benefit there and obviously in a real programming language you're going to use a multiply command instead of using the add command eight times but this is just trying to teach you the fundamental concepts of coding so I I think it's a good example even though it's not perfect so let's do the next one okay it wants me to multiply by 40 and put an outbox okay that seems like a pain in the butt why 40. so I I feel like there's got to be an optimal solution I've got to think of because obviously I can just paste in the number 40. I like the ad here I can just paste it in 40 times but that's going to hurt my fingers clicking that many times and also this is supposed to be a more difficult challenge than the previous one but what's weird is it didn't tell me how many times I was allowed to use the ad command um so I guess we should use the same concept as before just to very quickly get to a large value so 40 times 3 should be 120 and if I do three plus three there would be six here and then six plus six should be 12 here and then it should go to 24 48 um what is 48 plus 48. okay that's 96. so this last one will give me 96 six it won't quite be the 120 it's supposed to be but I probably could add one of the previous values to get to the final 120 and I think that pattern would still work so I'm gonna try that so after I add the first time I'll copy to the second one I try the second time copy here then oh I need to make sure I'm adding the correct one as well three add three uh copy to four so I mean this is less painful it's harder to wrap your head around than just adding 40 times and in fact I don't even know what value I'm at yet I think I'm at like 90 something so I'm just going to run it to C and I know I need to be at 120. okay 96 so if I take 120 minus 96 then it's 24 so I just need to add the previous value and I think that pattern will be consistent so then I'll just also add a third one here and then I'll put in the outbox so we'll see if it dislikes the way I chose to do it but I think it should work there just may be a more optimal solution oh wait that's 240. I went twice as high as I was supposed to oh no let's see six was the original I forgot before it was number three it re-randomized the number so now it's number six so 240 should be correct so 6 times 40 yeah that's 240. so I just forgot my jump is all replay fast forward zero times forty that was a lot of steps to figure out but there's still zero okay I liked my solution okay so those are challenge problems so I'm guessing this next one won't be so hard because it's not a challenge oh the floor got different okay anything that's not zero it wants me to put in the outbox so any these zero values it wants me to not put in the outbox I've got a new command here which is Jump if zero so I'm not really sure why I need the floor at all unless this jump of zero requires uh yeah it doesn't when I dragged it in it didn't have any parameter uh so it's got to be just looking at what's in my hand so I think this is all I need to do basically grab it from the inbox if it's zero jump back to the beginning which will grab a new item from the inbox if it's not just go to the outbox so I don't need the floor at all because I'm not doing any kind of math oh I guess I need a an additional jump that's not conditional that also goes to the beginning and in this case it doesn't matter uh if how I do these Loops because both of them are just going to go to the inbox but it's probably less confusing to not have the arrows across each other just so you can visualize it logically but they do the same thing speed about it okay looks like I got it interesting so maybe it's these two oh I'm just realizing the busy mail room there's a light that's dark so maybe all of them are challenges I accidentally grabbed the same level us maybe all of them are challenges and this second one I failed part of the challenge I'm not going to worry about going back okay send only the zeros to that box so this is identical to the last one except just how I want to jump is going to be slightly different um so if it is zero then I want to go to the outbox but if it's not zero okay so this is a little weird the way I did my jumps but basically I'm gonna grab something from the inbox if it's zero I'm gonna jump down and then if it's not zero it's going to go to the next line so that's going to jump back to the top um but because the if zero jump like skipped line three it's not going to jump to the top it's just gonna go to the out block so I think that should work uh oh I got ahead of myself I wanted to just fast forward because I knew I had the right answer but I forgot to do the final jump at the end to grab the other items from the conveyor belt so essentially it's teaching you what an if statement is but it's teaching you from the most basic concept which is a jump an assembly language which is the language before C plus plus um or before basic uh Assembly Language uses jumps for the way it does if statements because it's more basic um so I guess it's saying I didn't quite pass the challenge because I used too many steps I don't think I'm going to worry about optimizing it I'm just going to move on okay now I've got subtraction instead of just addition so looks like it wants me to subtract the second look at the first from the second so two so it'd be seven minus two I believe and then go to the out box but then it says to subtract the second from the first so that would be negative five like two minus seven so it wants me to do it in both directions and put each of them in the outbox so because doing the addition or subtraction modifies what's in my hand uh if I pick up a value well so first of all add and subtract have to go off of the floor but also whatever values in my hand it's going to get lost so I think I need to drop these down on the floor first before I do the subtraction because otherwise if I just grab it off the Inbox and then do the subtraction I'll lose my original value and since I have to subtract it both ways I can't lose the original value the first time so grab it from the inbox put it on floor grab it from the inbox put it on the second part of the floor then I can start working on my subtraction so I'm sure for the challenge it's going to want me to use the fewest commands as possible so I should think about what's already in my hand uh what's already in my hand it's the number seven and it says it wants me to subtract the first from the second so since I already have the second in my hand if I subtract this first value then put that in the outbox then I need to do the opposite direction so I think I need to pick up this zero so that would be a copy from zero and then subtract from one so I'm just doing the opposite direction as before or put that in the outbox and then I'll just always jump to the top because I need to do all the conveyor belts see what happens two seven seven minus two five two minus seven negative five okay let's fast forward and see I did it right looks like I did so I think you know they're color coded green when you pick them up off the conveyor belt I assume if I put the wrong value on the outbox it would color it red or stop my program immediately so maybe sometime if I get an answer wrong I'll notice that okay so it I think it wants me to grab pairs at a time so here five and six would be a pair seven and seven would be a pair and then negative six and eight in it as a pair and then if the two values are the same put only one of them on the outbox if they're not uh it wants me to throw them away so like the five and six will get thrown away and a single seven would get put so I don't have a compare parameter in here but I do have a subtract so if I subtract the numbers and I also have a jump of zero If I subtract them if it equals zero then that would mean that they were equal and in my hand will be the number zero so I'll need to pick up that original value off the floor input in the output and then it's saying I also have comments in here so in case I want to just oh I have to drop um so comments are essentially to explain to other programmers or even to yourself like if you don't touch the code for a few months and come back to remind yourself of what you were doing and why I'm not going to bother with comments but so I'll grab basically the number five put it on the floor at spot zero then I'll copy or I'll grab the number six and I don't think I need to actually put it on the floor anywhere I can just subtract it from zero and then uh or from the spot zero so five minus six is going to be either one or negative one I'm not sure what that to think about which direction it doing I think it's gonna do six minus five so I think it'd be a positive one but regardless it's not going to be zero if is zero I want it to put it in the box but what's in my hand is now the number zero well technically in this case it's one and I don't want it to go in the outbox but if it were zero I don't want the zero to go with that box I want whatever was on the floor to be in that box so I'll have to copy from the floor first in that spot and put that in the outbox so if it's zero um if it's zero I'm going to do this copy and if it's not zero I'm gonna go back to the top of the program and grab the next item and then at the very bottom of the program I'm also going to go back to the top so I think that should okay so I got my number one it says it's not zero so it skips over it puts a seven down this one should be zero so grabs a seven puts in that box okay perfect looks like I got it year 13 we're moving forward quick okay so it's saying I could have removed one single step to optimize it slightly better but again if it's working I'm not going to worry about making it perfect but like optimizing it for Speed you know it's fast enough it just did one extra step when you think about you know programmers get paid a lot of money and so if there's not a difference that's noticeable to a human in the speed then it's probably better to move on to your next task rather than trying to optimize it to be as fast as possible I mean computers get you know they double in speed every couple of years so you know if it's noticeably slow you should fix it but if it's good enough just move on you know computers are not nearly as expensive as a human you know like uh paying the salary of a programmer for a whole year might be over a hundred thousand dollars buying a computer is a thousand dollars you know so if your program's too slow just buy a faster computer it's cheaper than having your programmer you know modify the code unless it's like super super slow or or it's like a really easy fix for the programmer to change it okay so it looks like I have more commands I have jump if negative now and it's saying that I only want to I want to take two pairs of numbers and whichever one's bigger that's the one I'm gonna put of the two into the outlaw so essentially If I subtract them the negative should tell me which one is Big so I'll grab the first number and put it on the floor then I will grab the second number and subtract it from what was on the floor and then if it's I just have to think about the order here so uh two gets put on the floor nine is in my hand now I'm subtracting two so nine minus two would be seven that so the negative in this case would actually mean um that the second one was smaller but because it's positive the second one's bigger and I want the bigger one to go in the outbox so if it's negative I want it to go into the outbox but if it's uh oh this is a little tricky too because it if it's not negative I need to grab so the one that's in my hand is what's going to go in the outbox oh actually no because I subtracted so the number two is still on the ground the number nine is not in my hands anymore because I did the subtraction it's now set so I've actually lost my original number so before I do the subtraction I actually need to copy it to the second part of the floor so then I'll say if it's negative then I want the second value so I'll grab the second value and put in the outbox and then if it's not negative I'll grab the first value and put in the outbox and then in both cases I just want to jump back to the top so that it does the other numbers I think that should work oh I think I got a backwards so I grabbed the number two and it wanted me to grab the number nine so the proper thing to do here would be to like do this debug and figure out what I did wrong rather than just guessing but I mean it's pretty obvious um that I just grabbed the wrong item here so just swap which item I'm copying before I put it onto the outbox so debugging kind of lets you step one task at a time and see the result and you can see it while it's just doing play but the pro problem is it's going too fast so if if it's going too fast that you can't think that quickly then that's when you would do the debug but you can kind of see this green arrow is showing which command it's on so um you know even without debugging and you can kind of get an idea just by visualizing what's happening and it was nice like the very first time I put a bad value on the outbox it immediately gave me an error so I didn't have to watch the whole video to see if I'd made a mistake or not so same as before it's saying I could have optimized it maybe someday I'll go back and find an optimal solution but I just want to move on to the next task so I think this is just another coffee break so it's not actually going to give me a task just have to watch it ooh scary a massive Army of machines are outside of our building but they're not communicating with us I wonder what that means are we under attack let's do the challenge on the left first no new commands put a zero in the outbox if they have the same sign so so if they're both positive or both negative do a one if they're different signs so again I reach you know grabbing two pairs of items at a time so this first one there have opposite signs uh so that would I need to put that one out and then the second one negative two negative eight that the same sign so I put the zero it's nice to put the zero and one on here in the floor for me otherwise um I don't know how I'd do it so grab a value um put it on the floor grab another value and since the seven itself doesn't need to go to the outbox it's a zero one I can just do the math I think I need to subtract them but now I'm wondering can I do that so like if I add negative seven and seven together it becomes zero so I'm not sure by adding or subtracting that it really tells me that they both had the original same sign I feel like I almost have to add or subtract them from zero to figure out what sign they have or oh actually I could do a jump if negative so if I grab the negative seven and it's in my hand I can do jump if negative to tell me if it's negative and if it doesn't Jump Then I know it's positive so then I can do the exact same thing I grab then I grab the next number which is 7 and do the jump so I think that's uh so it's going to be kind of complicated code but basically and this is actually a good point to think about adding a comment so I wish I could type in here but I'll just type A negative I'll draw a negative okay so um so if it is not negative then obviously it's positive so in both cases I'm going to grab another item from the inbox but if the first one was positive then I'm only going to put well I guess depending on if it's positive or negative for the second time tells me if I'm using this zero or one so I'll say JUMP if negative um and out box and then jump back to the beginning copy from so I'm I'm not actually picking the uh correct zero or one yet I'm just getting the strip overall structure correct for okay so I've done the positive Branch I just I'll basically do identical for the negative branch and it actually looks like I have a copy command here oh I guess I can't well can I paste it in here I guess I probably can okay uh it looks like it's gonna clear out my whole program if I pay so that's not going to help me I was hoping I could just oops didn't mean to drag that I was hoping I could just uh select a few line item a few commands and paste them so let's just step through this I've only done half of it so far but grab the first item uh if it's negative jump down so we're we know we are are right now in the positive side now grab another item if it's a negative jump down again so that means we've now got two positives in a row if we're on this copy command so two positives in a row should mean they're the same sign so that should mean a zero and maybe there's a better way to do this this is just what came to my mind so I'm supposed to grab the zero and put in the outbox now because I've put something in the outbox I'm ready to move on to my next pair so I'm going to jump back to the top of the program so this next uh jump was if it went from positive for the first and negative for the second so in that case instead of grabbing a zero like we did here we're going to grab a one because the signs are different put in the out box and then again jump back to the top of the program so now um if the very first number was negative it's jumping me all the way down here where I've got this column that says negative so I'm going to do the same structure as before so we had inbox so I'm just going to do jump of negative copy out box I'm just going to do it like identical and just change it slightly so negative copy outbox jump copy out box jump okay so this should be the same I just need to move my jumps to where they go and copy from the right place so the first value is negative and then let me get these correct first the jumps okay so if the first value is negative I'm going to grab the second value and so that actually matches our real case here negative 7 is the first positive 7 is a second so jump if negative down it's not so it's going to basically be negative then positive so in that case I believe I'm supposed to give it a one so grab the one put in the outbox go back to the top of the program now if it was two negatives in a row instead I'm going to grab the zero put an out box and then again jump to the top of the program so I think I've done let's see what happens it looks like it's working because it hasn't given me any error years so I'll let it finish nice okay so there was a much more optimal way of doing it than what I did but it might hurt my brain to figure out a better way so sometimes you don't need to worry about what is you know someone else might have a different idea than you and it's good to ask for advice you know or brainstorm before you start coding something but in the end if it works it works so maybe there's a better way I could have done it but I chose that way and it worked and something might be faster but it could also be harder to understand like to be honest the last solution I just created I felt like it was confusing I like it was not easy to understand so you know I think the most readable solution is the best solution and then afterwards um you know the fastest solution unless you have a specific reason it needs to be faster so yeah my my last solution probably could have been better okay so it wants me to Output all of these values from the left to the right except that it wants me to convert them to positive if they're negative I'm wondering if I subtract it from itself if that would convert it to positive but I think I'd have to do it twice so like negative 1 minus negative 1 is the same thing as plus one so that would make it zero and then if I'm minus it by negative one again it would do another plus one which would change it to positive one I think that's the right way to do it so I'll grab it from the Inbox and if it's positive which I don't have a jump if positive so I have to use the jump of negative um but I'll say if it's positive then it's just going to go straight to the outbox and then back to the top of the program if it's negative then I think I want to subtract it from itself twice but when I do the subtraction it modifies what's in my hand so I have to put on the ground first so I will put it on the ground then I'll subtract it from itself and then attracted from itself again I think that will turn it to positive then I'll put it to the output or outbox and then I'll jump back to the top of the program I think that should work one goes over I'm hoping that this changes to pot to zero and then positive one yep okay nice it says I could have used one fewer command I'm happy oh I get a sabbatical so instead of a coffee break I get to sit on the beat um I would be excited but this beach looks kind of nasty and ugly I'm not going to say anything derogatory about those ladies but you can decide for yourself yeah this beach is not very attractive and am I drinking hot cocoa on the beach that's kind of a weird mug I would think I'd be drinking a pina colada who knows okay oh this one's weird so I got tuna commands called bump I actually don't know what those mean but I'm guessing it's kind of like adding it by one or subtracting it by one so if I drag the sound of the question mark it'll tell me yep I was right okay so it's just adding or subtracting one to it and it's saying it wants me to Output like a countdown so if I grab this number two it wants me to count I think down to zero so like I put out two then one then zero but it says if it's a negative I need to go up to zero so negative six that negative five negative four I'll tell you it's the zero okay um interesting so I'm gonna grab number two and I am gonna put it in the out box but first I need to put on the floor I think so I'll put on the floor then put it in the outbox then I'm going if it it's okay first of all I need to know if it's negative or not it's because in the case of negative six I'm going to have different logic so I'm going to skip over this out box if it's negative so first I'm going to deal with just a positive case so put in the out box if it's positive then I'm gonna because it was positive I'm going to subtract 1 from it and I'm going to put in the outbox again but I need to be careful here because so the first and then like I'm going to have uh basically a jump that keeps subtracting by one and putting that out box but what I need to be careful of is I want to stop jumping once this value becomes I guess I could do it once it gets to zero I was going to do it for negative but then I was nervous um in this case like when I'm going from negative six to up to zero um I don't have a jump if negative well I'm sorry I have a jump at negative but I don't have a jump of positive so actually the jump of zero would be better because it should work in both situations so uh jump of zero two I'm basically just going to be done with the whole program if it's zero well not the whole program but back to the beginning of the conveyor belt the next item on the list so um and then if it's not zero I'm just going to jump back to the bumping bumping the negative one so like in C plus plus uh you would just say negative negative to subtract one and then or plus plus to add one and that's where C plus plus gets its name is from that shortcut of plus plus so grab the two put it on the floor it's not negative so it's gonna move to this out box put two on the outbox subtract one from that floor put it on the outbox which will be a one and then um it's not zero yet so it's going to skip this jump and go to this jump which is going to tell it to subtract again the only issue here is it I think it'll this will work in this example but if this were the number one uh the very first time it's gonna bump it and put in the outbox actually that would be fine too because that would that would go to zero so I guess they should be if this was a zero if it put a zero down here and then put it to the outbox it would subtract it to negative one and then it would put it in the outbox and then it would not be zero because it's negative one so it would keep jumping up here and it's going to keep subtracting we'd have an infinite Loop where it just kept um doing you know every negative number until negative Infinity so I actually need to check this zero condition earlier so if before I even bump it um and now an output I need it if it's zero I need to quit out the problem with that is um okay that's fine so and then the second jump I need to make sure that the second jump goes above the jump F0 so that it still checks for zero every single time so this should work and then this only handles the positive case so now this negative case I need to handle and it's going to be identical as before or just with slightly different parameters so it's gonna go to the outbox then it's going to above zero and it's going to bump it up instead of down and then it's gonna go to the out box and then it's going to jump back to the top here where we were okay so this jump of zero should go to the top of the program and then uh after it increments by one and that puts it on outbox it should Loop basically to jump back to where it's adding one and it keeps doing that until it gets to zero so I think this should work empty value you can't jump if zero with empty in your hands okay I guess that makes sense so because I've put it on the ground or put it on the app box I can't check what was in my hands that's a little Annoying um so I need to do the condition first before I drop it down um so I have two ways I could solve of this okay I I was gonna say I could cheat by just rearranging where I do the jump if negative but I intentionally put in this order to solve the situation of zero which I got an example of zero here so I do have to think of that scenario um so I guess anytime I'm gonna do a jump I need to uh first just grab the value off of that floor a second time so when I have the so I don't actually have a copy from uh just a copy two so I just need to add a copy from that grabs it off the floor how to think of where to put it um basically as soon as I put in the outbox it's no longer in my hands so right here this jump of zero is not possible until I copy that Value First and because I'm when I'm doing the bump it's not like an add or subtract where it's only getting put in my hands it's actually modifying the value on the floor so it's fine for me to just copy directly from the floor because that should always have the value in my counter so you know bump is technically a shortcut to basically doing a copy from the floor subtract and then copy back down to the floor so it's just a shortcut which is nice I mean programming is all about shortcuts because your code gets really really long um if you don't use shortcuts so uh typically the way you do that is you'll take a whole bunch of code like I have here and where it has this like copy and paste concept you basically would copy the whole thing and put it into what's called a function you know bump and jump and add those are all like functions so I basically create a function for all these commands um and then I could reuse that function so that like internally you can inspect what the bump commands does but you don't need to you can just trust that it you know does what it's documented to do without actually reading the internal code so anyways after this outbox I need to do the same thing which is the copy from and I think that should fix my program yeah it looks right perfect I think it might tell me I didn't do the optional solution we'll see yeah not optimal but it still works okay next level okay next task multiplication Workshop okay so it sounds like I can now put labels on the ground and um the benefit to that is essentially what's on the ground is like a variable in a programming Lane and so by giving it a name it'll help me remember what I'm doing and why so it wants me to take two groups of numbers and multiply them together this actually seems a little bit tricky um I think I'm I'm not I don't know why it already put some code in here for me it doesn't seem like useful code so I'm just gonna get rid of that um so I think what I'm gonna have to do is basically a loop to do the multiplication and when you think about the fact that it's building skills on top of each other previously I had to learn how to count down to to zero so I'm gonna use that very similar code so if I wanted to I could hit back I could come into this countdown and I could copy the entire section of code and then I could go to this new one which is the multiplication and I could paste it all in with just some modification because essentially to do multiplication I kind of want to count down to zero while adding to itself so I'm not sure why I need this variable that starts with zero doesn't seem like that's necessary but so let's just make a few variable names here so one I will call result anytime I write a function I typically just make a variable called result and that's like the final value so that's the multiplied value and then I want to make another one that's the count I would say count down but I just don't have enough space to draw so I copied everything in from this other program and I only wrote a couple minutes ago but I've already forgotten a little bit about how it works but I basically uh that's gonna go into my account and it's what I'll use to like bump up or down to get down to zero I know I'm done so I guess the first thing okay when a reason a value copy so instead of copying it to zero I think I want to copy it to the count and I think I still do need a difference between negative and positive because it either needs to count up or it needs to count down and then I'm technically adding the value to itself so I think I might also need a variable of like what it is I'm multiplying um it's important to have variables that have good names but I honestly can't even think of a good name for this like when you're multiplying uh so I guess here's something I can think of a lot of times when you do multiplication so you have like a variable a times variable B so I could think of b as like the count which is how many times I'm multiplying and then a as like the original value that's being multiplied so I guess I'll just call it a so at the very beginning I'm going to grab from the Inbox and then put it on a then I'm going to grab from the inbox again and I'm going to figure out if if it's negative or positive so it knows if it's counting up or counting down with that bump command and so these bumps should actually all come from the count uh in the previous program I was used to using that top lip it's based on the floor um but it should have been the count and then as it's counting up or down I need to in addition basically add a to the result so the initial value where I copy it to a it's essentially also getting copied to the result and then each time I bump the count I'm going to oh before I output because I was as I was counting I was putting it on the screen I don't need to Output it anymore so those can go but the after I bump it I need to grab what's grab what's in result add a to it and then put it back into results so so I'll read a then I'll add result and I'll put it in the result and I'll put those same three commands after this other bump down here so read and technically I could do it in either order I could read results and add a or I could read a and add result doesn't technically matter oh and yeah but when I copy from us putting into my hands on my ad it's putting it to my hand so that's why I have to do topic two afterwards I feel like that's everything I need except for the final output oh it told me not to worry about negative numbers I already coded it for negative numbers or did I because when you multiply uh yeah I think I did handle negative numbers so um it told me not to but whatever I already did I was worrying about if when you multiply if it changes the sign from positive to negative but it shouldn't it would stay the same so the only thing I need to do is uh output it so I need to know when is it all the way done and I guess that would be the where it does this jump if zero um so originally these jump if zeros were up here it should have been up here at the top because it's like grabbing the next number uh the only thing is I actually kind of need like an out box right here so that after it's done doing all the multiplication it's gonna put the final value in the outbox the problem with that is because I'm gonna jump into the top of the program uh the very first time the program runs it's also going to Output but it hasn't even grabbed anything from the inbox or multiplied it yet so I can't put the outbox there so instead what I'm going to do is do the out box at the very end and then put a jump at the end to the very beginning and then the ones that jump to when they're all done with the multiplication I'm going to put them at the end so when multiplication is done it'll output it'll outbox and then go to the okay I think that's everything so I really should have saw solved it from scratch and then I could have not even thought about I'm gonna pause it real quick so I should have solved it from scratch and then I could have not even thought about the negatives which would have over like simplified this quite a lot so it's definitely going to tell me that this is not the optimal solution because I actually handled negative numbers so you know maybe it's good or maybe it's bad that I copied the old code I don't know um it was similar enough to reuse the logic but maybe I should start over but anyways let's just watch it and see if it so grabs the two puts in the a no wait wait wait okay so I wish there was a pause button I should have done the debug I got nervous because I was putting two into result and I thought that was wrong but it actually was correct because uh it's actually this the second value is what goes into account so it actually was fine so four should go into a and result and then five should go into count which is oh it threw five away and put one into account so it actually is wrong oh it's because I've got two inboxes here on accident I'm not sure how I did that so four goes in a n results and then three goes into count so when I was grabbing the inbox the second time it was throwing the value away so now it's decrementing it to two adding them together decrementing it to one adding it together and decorating it to zero adding them together and then it should put that on the outbox oh I put the zero on that box which is not correct um the second thing I need to figure out is so so before I do the outbox I need to read the uh result value so I'm going to rerun it again and what I need to pay attention to is if the final result is correct so in this case it should be two times two which is four so if it goes up to like six then I'm actually counting one extra time or that's good so far okay so it is actually adding one extra time so it's putting six on there one it should have put four on there um so maybe to simplify this since it says I don't have to worry about negative numbers I could delete half of this but the important thing I think I will so jump if negative this command goes down to here uh so I think all of these oh yeah okay so I think all of these commands here um can be removed because that's the negative situation which we don't care about jump is negative it's not necessary um so I just need to think about how oh so I think I think the reason it's um incrementing it uh one extra time is because I put the value in the results initially um so instead I should just put the value 0 into result initially uh the other way I could do it is I could just immediately bump the count before I check if it's zero so both of the situations both of those options could work um if I had like a jump if um yeah if I had different versions of jump besides zero and negative then maybe I could also prevent it from doing it one extra time because normally in like a c plus type language you would have a loop that's either called a for Loop or a while loop and four does it a certain number of times and so you could say like one to ten but where while you do a specific condition and you can type up any type of condition you want but those conditions you can do a great then or you can do greater than or equal and so in this situation normally when you're just doing it one extra time more than you want you just change it from greater than or equal to just greater than so that it skips over it's so like I'm counting down to zero I basically would say skip over the when it gets to zero just only do it when it gets to one essentially but I think the easiest way is I'll just grab the number zero from here and I'll copy that into results so rather than copying the number four into result I'll copy zero into result that will prevent it from multiplying an extra time it's probably more than one way I could have done it and uh it's funny in the very beginning I said I didn't know the purpose of the zero but I ended up using it so I guess they knew what they were doing so the number four I think it was supposed to get multiplied three times I wasn't paying close attention but if so that would be 12 maybe it was four times let's see if it gets it right all right 16 goes into outbox okay you think you've been there so next it's nine times nine so if I remember right that's like 81 so yeah account starts at 9 goes down to eight so I'm going to speed this up and just see if we get an 81 on the right side I think we should yep yeah I think I got this it's kind of fun to watch the guy jump around and do all these weird things but it helps you kind of think through the logic obviously this is the worst possible way to do multiplication uh is to add the number over and over again there are shortcuts to do it faster but it's trying to teach you the concepts I'm pretty sure like in the next round it's it's going to give me a function called multiply so I don't have to do it this way anymore because in essence I've now figured out how to multiply using addition uh now that I've learned that I should be able to just use the function for multiply directly instead of doing the complicated way with addition so not the optimal solution but good enough for me it looks like I'm at a Crossroads again and looking at the rest of the game it looks like I'm about halfway through I've got the green area to solve and a little bit of the blue area and I already solved the yellow and half of you know most of the blue so I think it's a good stopping point I think I'll do a round two to finish up the rest of the the game uh because we've been going for about an hour now that's probably long enough but uh stay tuned for the next one I I do think this game is actually kind of fun um and it honestly does teach you the basic concepts of programming it more is teaching you how to think so whether you're going to use C plus plus or JavaScript or python it doesn't matter in every case you need to think like a programmer which requires solving logic puzzles in a way and that's exactly what this is doing so even though the actual commands like that bump command it doesn't actually exist as far as I'm aware in any programming language but something extremely similar does exist like in C plus plus is the plus plus or minus minus it it does the exact same thing so knowing the concepts and knowing how to think logically is what's important and later on you can learn the actual syntax and names for everything in the language so thanks for watching let me know if you have any suggestions on other games that I should play I think this one's pretty good if you want to pick it up I bought it on sale from Steam I think it was like five bucks so totally worth it in my in my book so thanks for watching