CodeWars.js ep.001 - Coding Challenges with JavaScript

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this new I don't know series I don't know how to call it Wow look at those very people oh hello everybody who joined in the livestream we're live but not with the usual free code camp curriculum series I've been playing with code words for quite a while and I thought that this will be something very fun to do for those who don't know what codewords is is basically coding challenges which you can do using different programming languages I'm doing it using javascript but you can use I think most of the natural at cb2 to to - well somewhere they have the languages look at these Python and C and all of those languages I've been asking people on Twitter what I should do well if I should do called worse and they were pretty excited though have my now for those of you who don't have a codewords account I highly suggest you create one it's free and you can climb the ladder with me so far I've been completing 132 Coty's the problems here called katas naturally I pronounce it right and each of the Kappa have a as a Q which is the level at ur some information and a quickie not sure well so basically you have this cutters and they have different difficulties the 8q and 7q are the easiest then you have six F five four and three and two and one which are the hardest I never did that two and one which would be interesting to do in a future livestream not today this is a pilot episode I think should we call it where I'm going to see how this works feel free to ask questions whenever you have a question just let me know oh wow 31 people that's insane where have you been a little less change oi male blank expression beehive on Oh God whoa and look at that for the purpose of talking a lot in the chat all right and Kate Rahman welcome all of you awesome okay so for today I think we can just do a couple of eight and seven cues you know a salute even I guess people don't like quick again well I think they do they just weren't around well a lot of subscribers also with a crazy day a lot of people subscribe like over 5 not 600 by now a republic of china' welcome okay I think we can start with an easy one maybe let's do an 8 we can select the difficulty here and I'm going to do them with JavaScript when we get to 6q can we do the partial keys one I got stuck with it sure just send me the link and or remind me if you're in the live chat just remind me when we get there but knowing that if everything is good with the sound with the video and everything I know also if one of you is a designer I would like to help me design a thumbnail for this new series that will be awesome and I'm not also sure about the name code words that JSI called it because we're doing code words challenges in JavaScript but well I don't know as I said it's a pilot episode and we'll see how these girls okay let's start with an 8q which is the easiest I see I've done it maybe I don't know in the future I should create a new account and start from scratch I am at four Kuna or I just I could just continue let me know should I start from scratch or just continue on this account okay alright the first non-consecutive number okay this looks fun tu-tu-tu-tu-tu-tu - it has a lot of text I I usually am lazy to read all the text but your task is to find the first element of an array that is not consecutive by not consecutive we mean not exactly one larger than the previous element of the array okay so that's a lot of let's we can click a train button and now we are here in this nice editor on the Left we have the instructions and on the right here we can write our code and we have some tests the nice part with these challenges is that after you completed you can check it if it works alright tech need to get my I don't know how it's called ohms slippers Oh shoes those are real wearing in your house when you're praising the feet oh boy I think no one understand what that's it alright if you join the livestream say hi at any time feel feel free to ask questions and I will do my best to interact with you as much as possible and at the same time do the challenge good apparently dysfunction gets in an array of numbers and we need to find which one is missing I guess we can start with just looping over the array and find if the next one is not the previous one plus one I guess that will be the easiest approach to this all right let's do that so for I'm going to do an old for loop I less than or a dot length I plus plus like I'm waking up at one end to what your lesson okay so now I think let's see you will also be able to hear my top of my process because I am going to try to walk over everything I'm doing good so let's get the current one which will be array of I and then the next one which would be array I plus 1 right and if we do I plus 1 we don't have to go up to the array that length we can just skip the last or loop because we're checking here plus 1 hopefully that makes sense and if parent plus 1 is different than the next so let's take this array of this example we're checking this element with the next one if it's if this plus one is different than the next one then we want to return what we want to return this plus one right because in this case four and six we're checking four plus one is five and it's different than six so then we just return our n + 1 return our n plus one so that should do it for the base case now I'm not sure we do also need to check if [Music] but let's run the test and see how many big pass if they pass okay expected six instead got five your test to find the first element oh so we need to find the first element of the array that is not consecutive so not the missing element okay okay my bad so then we just return next because this will be six in our case MinMin are high have you tried competitive programming not yet okay so this should work with pass the test now if we click attempt it will try the test with more well it will try the curled with more tests this is so out is the subscription value to but all right good so we get the couple which are not okay let's expect it know instead that undefined expected knowledge that that undefined okay so apparently if we don't find something I guess they said it in the if the whole array is consecutive narrator no okay okay so read the entire instruction we can just return all here at the end because we're not finding anything and ananka see could take numbers here all right let's sit them now and look at that it passes now this it's not perfect because oh well actually it is because we're not starting from one we can start from whatever number we want so this this example is nice I was thinking if we could do it with a for each loop but we can't return from a 4h tulip so I guess this is the solution we're going to submit why not let's submit it and the nice part with codewords is that when you're submitting your your solution look at this you can find the solutions of other people in these cases well it's exactly as ours or look at that we have array that find value index and value different than index plus array that's zero well no this is some fun stuff victor number is integer result otherwise no okay so in the future we're going to try to do stuff like this which is a little more complex all right everything good so far are you cozy are you prepared I don't know let's do a seven one no addition here this looks fine no no addition what I'm ready no oddities here all right you'll see me fail a lot which probably will be funny but well not for me maybe for you who knows Laurene what do you do when we don't understand one of the solutions what do we do when you don't understand try to understand as much as possible if you want I would also suggest you go and get the code and split it apart see exactly what each line of code does but the good part is if that you're going to do these challenges with time you'll get better and better for example I had an experience when I applied for top Tao if you guys heard of those and they gave me to do two of these challenges in one of the interviews but I failed the second challenge because I ran out of time so then well because it was so close they allowed me to do it again and I had like a week until the next then re-interview I don't know how it's called and in that week was a week or two I don't remember 100% but I know that in depth week or two every time it was I played a lot a lot of cod fights was back then the website now it's called signal and I did probably hundreds of these type of coding coding challenges with JavaScript I did so many that if we go to github I also stored my own I created all the algorithms from scratch and if you go to repositories at all GS I think I stored it yeah all GS and here collections that is here i stoled all of this my own submissions for those challenges I think it's more than 1,000 lines of code yeah 1000 - so these are different functions for I don't know I before address check or product of digits of n or so I was doing these like crazy well as they do everything we do you think you and then well so I got to do the second interval the interval again and the second time I just nailed it I I don't know I had a lot of time left so yeah learn from my experience and do these type of things if you're applying for a company which you'll get these type of exercises and I'm sure some of the companies don't require them some of them do but I also do them for fun this challenge is I don't know I just like to do them with JavaScript kay get Oh enough talking let's do something right the function small function that returns the values of an array that are not odd all values in the array will be integers return the good values in the order they are given okay atmosphere to to do to do to do so no arts that means we should return the evils all right should I do it with the for loop or I should just do with the filter I guess just do with the filter so we can return values that filter here we get the value and we want the value to be its division by two should have zero remaining right so this filter method will go over all the elements from the values array and for all of the VAT of the elements we'll apply this function which will return the value modules to equal equals zero well this expression which checks if the number is even if it is and it's true then it will keep it in the array if it's false it will just throw it to the garbage so let's test this and look at that it passes now another way to do like for let I 0 I less than values that length I plus plus and then here you could do if values of I values of I modulus 2 is 0 then you can be a tenure a oops like that and here you would do array that huge values of I like that and at the end instead of this it will just return array that will be probably an easier to read if you don't know the array methods on JavaScript but yeah the the result is the same all right - let's if this council that and just send I guess secondly okay let's see maro there is a contest on code forces and it is a Division three content so beginner level it's not easy though I think you should try it rote technique yeah a code forces could you send me a link that looks how are you cos made Pinker cuz me from Facebook right all righty let's go to another seven or we should try the more that's one not six one yep so you can see that the same the same submission is applied so values filter and yeah or these easy ones the submissions you will see that they are the same because well it's an easy one and you know if you're playing enough you kind of know how to do it the I don't know that's this way your stuff but if we're advancing you'll see that there will be even more clever ways and we'll learn how to use regex and all the fun stuff okay so here we have a sixth queue which your ex to write a cipher simple cipher that rotates every characters in the range a Z a Z special characters will be ignored by the cipher by 13 characters okay we already did something like this in our quest to conquer freaking camp so I'm just going to skip it for now okay this is a 5-1 no thank you for now a 4-1 come on give us something easier for them well I just still here then and [Music] Marshall keys I don't like to read that much give me something simple someone suggested something Mekhi do you have the link to that partial keys oh this is the one that's funny okay so yeah if me I requested it he's been a longtime supporter of this channel so in his honor I'm going to try this see what happens okay I have some orange lemonade which is so good get it let's see the rap you need to make a function that takes an object as an argument and returns a very similar object but with the special property the returned object should allow a user process access that is by providing only the beginning of the key or the value they want for example if the given object has a key ID number you should be able to access his value on the returning object by using a key ID number or even simply ID number number shouldn't work because we are only looking for matches at the beginning of a key okay so I see what they're doing here we're getting an object with the property of ABCD and we need to allow on that object to say o dot ABCD ABC a B and a yeah that doesn't look that scary so let's try kay the shop keep up the good work that's what I'm trying all right I am so surprised 31 people are watching where have you been where I did odd words not the colors the pick up cap all right the trick hopefully you'll join in the next ones all right I have a lot of things planned for this channel so it should be fun whoa so now this is interesting I thought that we're only getting one of one property of the object but apparently we're getting the ton whoops right good so let's think we have object yeah a good thing to do before doing any of these challenges is to stop for a second and think through what you're going to do I always well I'd not always I sometimes like to even write down a list of steps and I need to take hello done welcome okay so the first thing will be to loop over the properties properties of the object next the second thing will be to p8 be 8 all the sub-string properties properties on that object right and sign them to the vet okay good so apparently we need like two loops do we get the object but how are they checking and subject the partial keys okay so on the subject so we need to return a new object with all of these properties I'm not sure so let's see-oh ABCD so all will be equal to something and then when it looks s that oh that okay so we need to return an object I think yeah so let's look over the objects properties we can do that by doing object that is object like that this function gives us all the keys of the object of the obg object in this case and then we can loop over all the keys like that so this will return an array of the keys and then on that array we're doing a for each on the key all right so now we should have all the keys which is good next we need to get the keys which are basically a string and loop over them also so let's do a four let I 0 I less than he that length I plus plus all right and now we can just create a new key which will be e that place from zero up to I I or I plus 1 so the slice method [Music] or we can I also substrain well I'm not sure let's see what substring does substring now you can you are free to search for the methods you don't have to memorize the methods you just have to know their existing all right so you can see here we can see what the substring does so we have the hello world and then sub sink one and four let me zoom in if we try it we get e ll so it starts at index 1 and goes 1 2 3 up to index 4 0 1 2 3 or Aki not included for all right so that does that we can do substring then we want to start from index 0 and go up to I first time I will be 0 which won't give us anything so we need to do I plus 1 okay now if we console that love this new key we should hopefully see all the variants of these key is provided that's the test and check okay look at that so we have for the AAA we have a a a a a a a b a b c okay so now we but all the properties uh how about using includes why would you want to use include Jeffrey Newton hi greetings okay so now we get all these keys what we want is to create a new object and on that new object well I get a lot of subscribers that's impressive on that new object we want to create a property with the value of the new key and that property should be equal to let's see our object ducky I'm going to go over what this does in second let's just see if that works new object return this should work not really written one pork is a na expected to trickle watt okay let's cancel that vlog our new object they think it's their new subscribers thank you to my new subscribers I'm not sure if they live or not some might not be life uh a is to what object that key objective key this will be to the kid it's upstream okay something's not good let's save the value here constant value will be the object that key if some spacing here and now this go here I'm not sure if the substring is well to the defect drink this should be the same issue now I'm not sure eh-eh-eh-eh oh I think I know I know what's the issue what's their expected output you can see that the a is overwritten you are creating the key a again the end necklace so you override it that's true okay so how does he want us to do that visitin one for the keys a na why not two so what's this let's go over this section again be aware that you could simply add all the partial keys one by one to the object however for the sake of avoiding clutter we don't want to have a JSON with a bunch of nonsensical keys thus in a random test we will test to check that you did not add or remove any keys from the object okay also if a key is tested that appears at the beginning of more than one key in the original object okay then return the value corresponding with whichever key comes first alphabetically whoa now that's interesting now okay that's quite interesting question from the chat if you cover all the freaking camp curriculum that you've done so far will that be a good start in front-end developer it will be an amazing start in my opinion hello hello there subscriber all right so now that's quite interesting we need to keep track of the key [Music] because if they overlap we want to have the value which comes alphabetically first but now I have an idea which should help so if you look here the object there provide us is in alphabetical order so a a a B C D F G and so on or is it the EF ABCDEF I guess we can sort the keys here when we looping over and then just reverse it thanks for making quicker cam tutorials does it make sense so let me show you console the clock object that keys of eg if we test this you will see an array of all the keys now we can sort this and now DF d EF should come before DF DF g hopefully yeah you can see there which is good now that is that's in alphabetical order but here if we go AAA and then we go ABC this a will overwrite this one so in order for that to not happen we can just reverse reverse this array so then we go backwards and the first one well the last one will be in alphabetical order will overwrite this one hopefully that makes sense but then we avoid doing all the checks and storing x' of the keys and check if oh well all that stuff now this should work look at that it works good if someone has a question regarding this challenge let me know if not then I'm going to submit it well actually let me quickly go over it so we get all the keys we sort the keys in alphabetical order and then reverse because we want to store the key with the alphabetical order but now before looping over here we're overwriting it we could also just go backwards so I is keyed blank so it wouldn't reverse it here well that will be an improvement but then the substring will change [Music] that's fine we're doing a loop over again here which is okay not the best thing but okay look at that so we have an error expected nine nine seven nine a to equal 200 now that's a 1 out of 206 usually those are buggy so let's constant that log the object to see what we're dealing with and also maybe we want concept to consider plug the you know object will you make a video how to grasp from w3c official Docs I never found a tutorial on it possible well I'm not sure what exactly do you mean w3 looks pretty look at that they get all of these console.log how can we find one is failing no way so we have a bug somewhere okay where's failing and we see the one who fails okay here [Music] how can I check for that the case when you have to keep when you have two keys I'm not sure what what two keys okay so that's bummer this will probably take longer than I expected with ID number and the d-string they turn on the final else block we turn on the final else block I'm not sure what that means either with ID number and the d-string I covered that we're sorting and reversing so that's covered okay for example you get the number okay understand this should be aware that you could simply add all these partial keys one by one to the object however for the sake of avoiding clutter we don't want to have a JSON with a bunch of nonsense NC copies what that way thus in a random test there will be a test to check that you did not add or remove any keys from the object passed in or the object returned I think this is the issue but I don't understand it exactly in a random test there will be a test to check that you did not add or remove any keys from the object passed in or the object returned what so we can add and remove from the keys now that's odd Howard the checking death this looks a lot harder for a 6q yeah so that doesn't pass and they don't tell us by I mean MC exactly what is this one this long one not random tests [Music] I have not run tests the case that's random should not have extra keys truck keys does anyone derstand what they want should not have exact mmm written various associated weight with with all of these are passing but not that one you okay why did I did start doing one which only 83% finished Oh 21 Oh No so 68% sixty people completely probably because of this test be aware that you could simply add all the partial keys one by onto the object however for the sake of avoiding cluttered we don't want to have a Jason with a bunch of num and sequel keys what this but without sense okay thus in the random tests there will be a test to check that you did not add or remove any keys from the object passed in or the object allowed to add is the object them all they want is the delayed yeah these kind of tests might just break your mode my building what were you saying their return and the finder palace boy you maybe skip the keys that already exists if the keys Eric's this okay that's actually good idea but then we want going to reverse won't go reversed because we're just getting the first one okay so if you object that key and if not then we're adding it now this new object that key could be zero so that won't work but let's try this now okay now apparently didn't work we'll swim like this regularity yes I have a trip planned next week but we are not sure if we're going or not as the virus but if not then I'm going to swim probably daily or I don't know follow me on Twitter or join our discord if you want and you'll be a you'll get notified when I do and planning to do a lot of life streaming videos and od okay so should not have extra key what are extra key you find something on github it seems it is done with proxy object I have no idea what axiom and a lot of subscribers I should probably decrease this easy buggy for you I didn't that exist let's see proxy proxy object basket let's look at that Roxy base or the object would contain straps which contain straps the target object to rap with props it can be any sort of object okay [Music] attractive or setting property values all right the proxy ability choose to define custom behavior for fundamental operators look-up assignment enumerators functional function invocation want to see an example can we see an example let's read this article yet any target left-hander equal yet furgus named Amy target the proxies used to define custom behavior you may run into terms constitutes ortley a three kids handler card traps and target be careful a stocky so he is new proxy not the object and handler I want object property look up Oh so how did how we'll look up like then Roxy Oh handler yet function oh wow that object properties balance property calls oh Orleans great want to achieve day by day while having fun unrelated question how you organize your time well I am not good at asking that question well I just do whatever I like and the parent play like code you can live swimming so that works fine do what you like and you'll be fine yeah this challenge is more than 6q I agree maybe - took you I'm probably not but they require some knowledge which is more than I could now handle nevertheless yeah they almost best which is it so let's just keep it and do another six one which well usually the six ones are pretty easy but apparently this one is let's just do something which consonant value this looks like was completed more times locust ring that has alphabetic characters only and note basis return the highest value of consonants substring a sense of any letters that accept those for example for the word zodiacs let's cross out the vowels okay fellas RZ the PS 26 all right for the strong 75 okay do not manipulate input mahaki so this looks even though it's more work looks easier well the last one looked easier to but alright so what we need to do is to loop over the string get rid of all the all the vowels so let's write function is vowel which will get this cherrick character get the character and it will return let's see the test No so I'm going to write to direct the regex or not well I want so let's create an array of vowels which will be a e I owe and you we're going to return if fowl includes see so if that is there then it is a vowel otherwise if this returns false all right next we have the vowels we now also need a function which gets the values so a will be 1 B will be 2 if you follow the log on Twitter you Oh correct you okay okay thank you see that's why I like having a chat active because you're helping me thank you okay function let's see we want to create a function character to value which will again get the character and lower case string so we want to return character character at charcoal car code at zero minus 96 I know this from the top of my head but what this does it will get the ash to ash T value of this character now if you're not familiar with the ash T table here it is we're getting all these letters or characters and we want to get their decimal value so we're using charcoal add weight weight which let me close this which requires at what index we want the character from so where we want the character at zero this will return us a number from this table for example 4g will return 103 now we need to convert this G to let's see 1 2 3 4 5 6 7 so how do we convert G from 183 next much prefer 103 - 9 - what was it 7 we subtract 96 laziest is to see with a so in order to make a be 1 we subtract from 97 96 and we get 1 so that's what this function does we have a is foul function which well should actually be is a consonant but okay and now we want to return our string which is a string with all well these words and we want to split that string into a list well internal array of characters so this function will convert zodiac to the O and D and so on okay so now we want to filter out all the bowels so we're going to use filter and we're going to pass in this is vowel now this will actually not filter out all the vowels but will filter out all the consonants so let's change this to is consonant how do you type it like that and instead of returning if the vowel include C it will return if it doesn't include it now that should work let's see what we get if we pass now we should get an array with all of the the consonants but I see now an error Ares that were splitting the string and we shouldn't suppose so because we need to find the consonant substring so instead of splitting this thing into an array let's just replace it place you want to replace the vowels with an empty streak but then we get the string with all the consonants and between the sub strings of consonants we'll get the space so we need to write here something and this is okay so then the East consonant function is not helping us much okay place is awesome [Music] yeah we're going to need to write the regex I'll forget this but at least now you know how to create a function to check for that and instead of yeah this is what happens when you're not planning the head like you're you'll start doing something and then halfway through you realize that it wasn't what you want okay so we need to replace the vowels which are a i/o we're passing them inside this bracket if you didn't sell my reg ex tutorial I highly recommend you do regular expressions floating pubs or to YouTube and it should pop up alright so all of those should be replaced with an empty string okay now I can see that on zodiac we get Z D and C with the space between DSC well two spaces but it's the end between D and C because we have two vowels now instead of doing than this we can check for one or more vowels and replace them with boxing but well before we checked only for all individual vowels but but with this plus we can check for zero or more power so now if we test we should only get one space between b and c which is what we want perfect now we have a string with all the consonants separated and also the group of consonants which is perfect we can now split it by space and we'll get all the pairs individually like that and let's see what we need we need to add up all of the individual consonants value and at the end we'll have a total value so we can map over it [Music] we need to apply this chart of value function so let's try this we can map over the substring or I don't know how to call it string or something and now if we do chart to value it will only work for the first one's chart code of zero okay so it will only work for those and where it will return the value for the first character which is not with what we wanted why would we have not a number there Oh an empty space kay so we might have a vowel at the end of the string or at the beginning of the string and with this we're going to create a space so we can just use the trim function which will remove the spaces from the beginning at the end of the string so now this empty space should go away case out awesome so that's good we are close now in the map what we want to do we have this string which what might be one or more consonants and we want to convert them to the value if you have any questions regarding all of these let me know [Music] okay so Steven says and we'll be play can someone explain what this kata is about sure so we're getting a string which has consonants and vowels we need to remove the vowels and add up all the substring of consonants values we get the values a B 1 a being 1 B B to C being 3 so for example and then do the maximum so what's the maximum substring of consonants values I guess I can paste the code in the live stream so you can also take a look yeah that should be a good idea from now on okay let's go back so what we have so far we have an array with all the substring consonants we need to go inside each of them and add up their values so I'm going to write another function which will let's see add up add up add up add up substring which will get the string and do what on that string we want to split it again in individual characters we want to map those characters character to value so we'll get the numbers and we're going to use reduce to add them up together we're going to have a cumulate ER and a current item and we'll do a cumulative plus equals item now this function here adds up all the items inside the van accumulator starting with zero so it will say let's see if you have one two three four example first it will check the item is one it will add the item inside the accumulator which by default is zero then the I to the next item will be two it will add up to the accumulator which is 1 it will become 3 and the last item is 3 it will adapt and become 6 so that's what this function does adapt substring okay now if we apply this function to our string well we can just do this then we should now see instead of an array of sub sub strings we should see their total value an array with total value okay look at that and now we have an array with numbers we need to find out the maximum from days so we can just wrap this everything on map that max and spread in the array we're getting and this should fix our little challenge but all right there was a lot of stuff probably went too fast now it's time for questions if you have any questions let me know I did I told you that okay orange eleven it is I told you that but there are a lot of small steps we need to do for this one we can now even try to simplify it but I'm not sure how I need to look over it maybe I just went too crazy about it we could you dredge it we could we could you know we could use projects to find all the substrings oh well okay so apparently no questions that's good I can submit it and let's see what alright look at these crazy submission let's see what it does could you not just make an object with the keys being the consonants and the bad is being the values you want you can split the string into an array and reduce it adding the key value to the accumulator that's an interesting idea but I don't know would you play the object on your own like all the consonants you also need to keep track of the spaces or remove the vowels add up those so yeah that's not a lot different than what we did we just instead of object we used in our array let's see what this guy did split by that so yeah exactly what we did oh he split it oh that's actually better we replace it and a splitted okay so that's doing one both of those things in one go and then reduced as a pen met that max yes and that split reduce okay so he used he used to reduces to do what we did your way were shorter anyway okay so yeah over time if you're doing this a lot like I started to do lately you'll start to learn a pattern especially when you're looking over what other people did so this is actually clever so let's give it a lever up I think King let's see this one ET the charcoal plus value please reduce Mad Max it's not very very intuitive ask that match okay so it matches all the non vowels okay get the maximum of mapping reduce okay so what we did but instead of splitting and replacing it does this alright yeah so that was pretty fun let's try another one if you have any suggestions of which one we should try let me know let's go these and short by popularity and do another let's try five I'm feeling adventurous I shouldn't I will probably fail okay any chance you could make this a weekly thing yes I want I can start doing that now because we're planning to go through in a trip but we are not yet sure we can because of the virus so anyway either starting next week if we don't go to the trip or either starting by the time we're getting home I'm going to do a weekly thing maybe one day of the week I could do codewords the other way the other day I could do some CSS HTML Javascript websites or maybe some games yeah Jess it's not safe I have a lot of things planned my idea for the long-term will be to stream daily for a couple of hours now I'm not sure the time zone is different most of you are lazy people and you wake up eight hours after I do yeah I'm kidding so that means I have to do the live streams at night but I don't know I wish I could do them in the morning for a couple of hours and then abdel-salam free to create more content I don't know let's see how that's how that goes Oh a rude well I'd from Europe your former from America so you wake up eight hours later so that's lazy to me [Laughter] and Katie I'm also lazy well I don't sleep much but Emily's alright the sample pairs that's hi this I'm from the UK so am i okay so Joey and Steven are not lazy they're just two hours lazier than I all right what given a list of integers and a single sum value return the first two values are from the left please look at that place if you please sure why not in order to put on appearance that add up to form the sum Oh entire Paris here earlier our case exporter [Music] okay somewhere there are no pairs of values that can be added to produce two none on the finest bade earned all right so this looks like whoa negative numbers and duplicate numbers can and will up here note there will be lists tested of lengths upwards to 10th house no thousand ten thousand times one thousand eleven and million elements be sure your kid doesn't timeout one thing I'm not good at at the moment is this making sure that the code runs if fastest either ass [Music] we couldn't do a double for loop I guess it will timeout yeah pick another one sure if you say so I have no choice I have to pick another one otherwise you'll be mad and I'll be sad okay let's pick another five one maybe do it the I don't know easiest five one why is this the easiest only 21 people did it I don't know of course I'm not going to read that all nested loop will loops will definite I need to learn how to do that kind of thing how to do those methanol maybe the only girl once and I really them okay next five can become please make it simple to understand I don't want to read that much I'm lazy magic five early they're all only finished a couple of times so that feels like hard to make okay let's do a 6-1 a couple of nights ago I did like three or four four ones which were pretty interesting but I'm not sure if I could do them not easiest let's make the most completed it should be look at that most completed and I completed them up spinning my words okay this looks fun I like working with strings and the race well I work with strings because I convert them to a race right the function then takes in a string of one of or more words and returns the same string but with all five or more lettered words reversed just like the name of this kappa links passed in will consist of only letters and spaces bases will be included only when more than one word is present okay this looks fun even said that he picks up just those that are less than three lines he admitted all right spin the wheel in the words this looks fun let's not rush into it and let's see what we need to do we want to loop over the words so we're going to split them in turn array loop over the words if the length is bigger than 5 we will reverse the string oh can you copy the linkage thank you thank you for reminding me I think I will need to stop this subscribe what I have does it bug you or shouldn't leave it I'm not sure the sound in my ear is powerful an answer if that's for you collect enough okay again loop over the string first converted to an array of words loop over the words find if the word is bigger than five the length of the world and if it is yes swap it well reverse it so let's write the function in virus sting which will take in a string and it will return the strings split by the letters reverse array and join back the array now this should reverse this thing good now spin words why don't you have something here Oh [Music] long string returned a long string pink we want to split it by spaces then map over the words and get the word [Music] if it is longer than if the word length is longer than five right five or more so like that then we want we do a ternary here and we want to do reverse ping on the word otherwise we just return the world I think that's it we now should have an array of the words we need to join them back let's see what we okay oh that looks fine I'm not sure if we'll have some spaces join them back so we split by the space we need to join them back by the space so yeah so compare this 6q with the one we did previously with that bunny test say the list oh do you have any questions before I submit it you have one two three seconds monkey that's how someone else did it the split map over the world if the world is bigger were that split reversed join otherwise world exactly what we did we just created this as a function hello accom I'm fine drinking my last I don't know 20 milliliters of orange juice orange lemonade I found that they usually only have one function yeah they do one-liners fool Johnny I can barely do four loops watching this seems like some alien coding no I'm not an alien I just did probably hundreds of these and I underst well I learned the array methods well you need to learn the array methods you need to learn the string well not actually know them by heart it's not necessary but to know that something like that exists be vigilant for coronavirus virus okay hopefully I this is why I'm drinking orange lemonade to increase my house that called my immunity I think this helps I know [Music] all right whoo that puts our next cotton how many we did I don't know binary simulator this isn't beta into beta I'll do present better some words sound funny from my mouth hopefully in a couple of months day month okay I'm tired hopefully in a couple of months they won't sound that funny anymore as I'm talking more and yeah should be better even a binary number we are about to do some operations on the number two types of operation can be done or I I J which means invert the bit from I to J you I answer whatever the it--but is 0-1 the amps the most significant bit is the first bit one the binary number can contain leading zeros so he wants to which means import the bit from I to J okay so invert all the beads [Music] I found that some of the cutters are just difficult to understand what we are meant to do yeah I found that too I saw one which you needed to create some kind of lights for cars so you had the road and you had to go with the car and see if the light is red then you stopped and it was by working on a string which was very odd I tried to understand well I kind of understood it but I just couldn't figure it out an algorithm to do it oh yeah I think this is also fun [Music] you changes to returns the bit right answer whether the is bit is 0-1 and so why is this so it changes the all the digits then changes the digits from two to seven then answers what yeah why is this returning you're only 5 Q at the moment just just do a couple of 4 Q's might take more a little bit but it will rank up let's see I am close to 3 hopefully it'll get to three I want to get top 1% Oh that will be fun but they think there's a long way okay so that was not that fun apink let's start try a fork you and look at all these people subscribing it was crazy I got let's see checking on my phone I got so far 900 no for with seven and for 700 130 subscribers today that's amazing I usually get 80 hello all new subscribers hopefully you like my channel top 4% is good me yeah but I want 1% I sent help and here because I can't find a solution to an error in getting my on my GS code we're not doing that well I guess this is the codeword specific word well send it on this Court maybe that will be better I'll help you there the more you do the easier it gets kind of find it difficult at the beginning yeah and really that's true so the more you do start with eight and seven then go six if you find it hard to go to the next one and yeah the more you do when you complete it just look at the solutions look at the solutions and see well what they did and try to understand what they did even that's because you're doing like live code words mate make it a weekly thing and what your numbers grow like crazy well that's because I got on Twitter I got a tweet which just went crazy one 1,200 like so far and it reached 54,000 people oh yeah and at the bottom I also have a link to my youtube channel so this helped how many people click the link 1160 people click the link to my youtube channel but this is why I grew cold journey give me the link I'm going to look over all right to to to to to to to but yeah I want to do this weekly as I said my wish will be to stream for three or four hours a day from Monday to Friday that will be like I don't know a part-time job which I really like hopefully it will help me financially in the future who knows for now I just make three dollars a day from ads well that was not requested most completed I'm going to post in the discord server under your help section ok perfect do that that's perfect all right so let's you can see that I did one two three four five six six of the 4 Q's permutations I don't like permutations next big number no big numbers I guess the observed pin this looks algorithms Oh [Music] all right TAC team one of your colleagues successful observe our target person Robbie the rubber we followed him the LA the keypad he noted in a pain whatever the master eat sorry their content is really good so just keep doing what you're doing and you'll start getting a lot more money from it yeah hopefully I want to work on some courses probably in the future which will help a bit hello even again you've been gone shame on you why be not you've been slipping didn't hear adding big numbers some of intervals twice linear just want to do something which is not that hard consider a sequence you wereyou is defined as follows the number used here is one is the first one in you for each X in you when cut X new and then Y is 2 what no and why I'm struggling let's just those sakes for now one day I want to do either one or two I have to have those under my belt please remember us when you who come to in the ritual [Laughter] hi um hi how are you okay so six let's go for does my number look big this a narcissistic number is a number which is the sum of its own digits each raised to the power of the number of digits given based in this card we will restrict ourselves to decimal base that for example take 153 1 3 plus okay now this is easy going from four to six it's big jump even I had to go for a little bit my people needed me I need you I'm there people I'm going to teach you how to pronounce my name though by Liam the fun LT I call you LP do easier ones as most of the people watching will be trying to learn so you can teach them higher order functions prayer the respirators callback functions things method as you go this core gang is here hello this car gang finally good so let's do this we get a number and we want to raise each of the individual numbers to the power of the digits oh that's simple right return we want to split the numbers to get all the individual digits and then or all the numbers do met that power to the power of the digits of the length eight digit we need we need a ditch it okay let me think let's get the length Oh Const pal string going to do a plus value and cost length will be vowel string not length okay so now we converted the number of not good like this like this so we convert the number to a string so we can get its value where it's selected and then we want to do vowel string that's flit oops we want to convert the string connery if you're if you'll follow along over the over this series you will see that whatever I do I end up converting either numbers or sings to erase okay I like doing that so split the number into a race then map over and convert them to numbers passing in the number function and then we want to use videos the accumulator and item and we're going to add to the accumulator met the power item to the leg okay no one must expect it true Oh so we need to save its narcissistic or not what that means but Nursing is a number which is the sum of its own digits raised to the power of the number of the beast oh okay so we need to check if that is equal to the number all right correct right so we need to return this equal to value all right good [Music] yeah now let me go over what they did again let's - I guess we don't need this map number we can just convert here to the number okay the length the splitting the whatever yes we turn through our fault yeah so first we get the number we need to get all the digits of the number so we're splitting the number well we're converting it to a string first and then we're splitting it into an array which will get all the numbers but the issue is that there will be strings now so 371 will become b7 and one like that so we want to add them up well actually first we want to raise them to the power of the length that's why we need the length and that's what we did here but first we need to convert them to a number we can do that by just adding a plus in front or if you want to be I don't know if plus is not good for you then you can do parse int but I just don't like that so at least plus and then we're using the reduced function which will go over all the items and it will add the value of this inside the accumulator which starts at zero okay using template strings is a clever way to convert a string yeah template leader yeah you can do that or you can also do Const Val string will be plus valid an empty string plus value this converts it to a string that's the magic of JavaScript all right any questions or cut for your information and just forget them off okay let's see this still works I had the map here because I wanted to convert all the strings to a number but we can just convert them here so we are skipping one loop over the entire rate which is good it's cool but your level is poor cotta let's all something difficult okay give me something difficult and I will fail most likely okay so plus values played videos plus that uhh okay accumulator plus method pow is converted to a string oh that's right oh that's clever actually so he did the conversion here but we don't yeah the one-liner interesting should we jump to one Kappa yeah sure why not let's see if we get the one cut the next and do one gotta whoa that's hard we need to summon array let's do that someone I need to summon array write a method that takes an array of numbers and return the Sun okay so let me show you the magic of reduce reduce takes in accumulator and the current item and we do to return accumulator first item starting at zero yay for some reason sometimes when I complete the a one of these easy ones I don't see my my points going up I'm not sure from where the string to a number when you can do any of the following to convert over string not sure what you meant there let's three do something more difficult keep in mind that it's 11:00 p.m. here so I might not be able to do that well I might be able to do that but not talk my way through I'm the missing letter right the function right the method that takes an array of consecutive increasing letters as input and that returns the missing letter you will always get an invalid array you will always get the valid see I can read number 55 plus rings ping times one yeah so you get a number from a string if you do all those that's exactly true I don't usually don't do those especially not strings that's their less than zero and not use with bitwise operation yeah and well that was poor English playing that means that you're ready okay should we do this or do another one we did something similar we find we found the number inside the burner were a welcome the missing number well actually not we found the last not welcome the next number two the missing number that's the fine [Music] tu-tu-tu-tu-tu-tu now we have a case here [Music] because we also oh I don't like this this bugs me it notes better we can have an array of lowercase letters or uppercase so we need to check for death first I guess or no let me think so we want to loop over the letters and convert them to well get the edge to value and if a sh t value plus one to the current item is different than the ash T value of the next item we just return that right yeah so let's good ol for-loop let I 0 I less than arena length I plus plus and here if const rent will be array you don't like to type a race let's change this a rate that I announce next will be array of I plus 1 and if well let's do the char code at 0 which will give us the SG value a if our end plus one is different than next then we want to return a string from char owed RM plus one which will do the opposite opposed I know the you you understand the opposite of what we did with chair cadet and we should go minus 1 we don't have to go till the less develop and we can return that is it possible to have not working one apparently all works fine does it make sense but you know if not there we go over what they did or I should just go over what I did without asking you I know not sure I'm looking over all the elements in the array converting the letters to the HG value so here whoa that's bright so a we're converting 297 B we're converting 298 if we're thinking this is our array we check if a which is 97 plus 1 is equals the value of B if it is we move on if it's not that means that B is missing so we just return B by converting from char code that was easy all right let's do a couple more I don't know I should go to sleep soon too late yeah so exactly what we did char array 0k first plus I different LAN okay so he is using I that's fine next returned negative X Fibonacci sequence no thank you we walk breathe a little verify are you a friend or foe please the monkeys I'm a monkey IP validation all right they like this right now going to depth will identify valid ipv4 addresses in that decimal format IPS should be considered valid if they consist of four octets with values between 0 and 255 inclusive input to the array is guaranteed to be a string single string my book uka fog be next certify is a fellow Romanian all right not now that leading zero are considered invalid now this will be fun all sports false false false false the truth okay so that added all the Gerudo with them together them today [Music] oh they're not for me met that floor string seems overkill yes okay I understand I feel projects coming on yeah projects that's the king you do [Music] let's see Oh first we could regex we need to check if the numbers are valid which are from 0 to 255 so for that I could just split the string you get all the separate value I could do something like return strings plate of duck and then this will give us all the individual items but now we also need to check if the length is four because if it's not then it [Music] also we need to he'll tire if were nor if the S is valid is valid ipv4 whatever so press that in or I guess we can just do is valid ipv4 and do this function here Oh is valid number whatever function is valid number X in the number and returns plus n which converts it to a number is greater than the greater than equal to 0 and plus number is less than equals to 255 now the issue here will be one we will get not a number two we might get 0 1 and this converted I think it's 1 which is also not good but let's see what we get so the filter we're hoping well we're splitting getting to the four values and we want to filter out all the non valid so if that's right we have four valid numbers we should have the length before and if the length is four then should be good now we will have a couple of test cases which will fail because of the mentioned conditions let's see constant a clock string or which one is failing a deep space okay expected for us cut through c01 how are we checking if it's leading zero no I think I know expected false instead we got through 1.2.3.4 white falls 1.2.3.4 why trying to verify if they consist of four octets with values between 0 and 255 okay so why is it this false and someone tell me I think you need to stick with the cold work streams yeah please 25 plus bill exactly well I only have one more section of wicked camp which I hopefully finish tomorrow and the day after tomorrow and probably Saturday and Sunday so in four days it's pretty difficult so I take longer when I survived Estonia marijuana Tarek fish top that's mister sir if I asked me to say something oh something : like how many languages can you speak three I can speak Romanian Hungarian and English and I can say no in a lot of languages like I can send no in French Katzie there is a space before one oh yeah there is a space before one that's true we need to be aware of that where are you from I'm from Romania okay so we need ooh [Music] check for that space let's see but look we don't have a space here which is also invalid this is also false why is this false we don't have all the right an algorithm that will identify valid ipv4 addresses in dot decimal format IPS should consist valid so you consider valid if they consist of four octets with values between 0 and 255 inclusive so this doesn't tell us exactly how an ipv4 should look like which is 9 how's the coronavirus situation we get like 40 people and you use pad to add that zero in front so we don't want that Achmed you saw me in the devil's name chat yeah that stream was crazy 600 people were I can say JavaScript no languages I don't know if I can say that I can make your own test get stuck oh you can make your own test well I don't need tests as we have them here so I understand that this is all but I don't understand why look at that so we need to check if this converted to a number it should be false how the chapel that's pretty clever you can also comment out all tests other than one at a time I never talked about that so we can just comment out all of those okay let's [Music] your death then thank you that's pretty clever I never thought about that and now we're testing we only see the ones which fail which fail because of the spaces so how do I count the spaces we can't count on the num because space too will convert the two and to space will convert to do so that's not good it guess we can also say and number asked for decimals zero no one or three only test the number so we can write this regex which tests if there are only numbers one or three numbers one or two or three numbers so that's no [Music] so error unexpected token Oh all right that's how I do it anyway I just get one working and family okay so our regex test failed why do I need to add this you just want to check yeah that's good oh and one to test okay okay okay let me do something else then I want to see console that flogged let me write the regex projects will be this D 1 and 3 and then I want to console that flog regex that test space 1 which should be false let me comment that out and see I want to write the regex for death through through no that's not true true I want only to start and to end what's the n1 this one with digits only digit all scoffs okay okay but now that works we start with a digit or three but a digit two digits or 20 how do you say better we start with at least one digit at maximum of B where is the dollar sign yeah all right so now that should work for those two ages invalid oh I forgot the parenthesis okay so now we should check if it's if it has a space or a letter or anything else good now that will work for more tests now but we still have the failed one with zeros I think Platinum of days is there any white space yeah ha that's how I did okay in my swing was miles behind Oh goodbye last chain hopefully you enjoyed it yes I am just refresh okay let's see which one we're failing to keep this six why is this hectic Falls got through why is this passing as Humbert then earn and we check if it's less than 255 yeah but we check maximum Oh what's wrong with that we check if the number is greater than equal to zero and less than equal to 255 and if it's a number let's do what even suggested and only have that test the test but best best value pops but they're messing with me Oh baseball field Oh I was looking at them wrong so this won't fail right yeah okay so 0 1 0 2 0 2 0 4 I'll do a check if it has a zero I could use regex put parentheses around your code and operate the proceedings cause a lot of hard to find by around the zooming you so I just need to check if that's Eva as living zero let's see we want to ask for zero but not for dear one what we can check if to convert to this one to check if this has a leading zero and it's a conversion to the number is not zero right oh and well nothing Hardware can check that if and what I'm going to do it here now and plus now if we have a leading zero s10 and n+ is different than 0 then return false so it has a leading zero and different than zero then it it's basically zero one and return false I need to incorporate that in this line that should work yeah left let's look for all of them okay 28 failed what Oh 0 0 is also net oh boy zero-zero is also not good I guess if we fix that well or n is equal to 0 0 or n is equal to 0 0 okay but this is just them but it works I think I don't know let's yeah look at that we hectic okay I'm tired and you can't think of a way to make this like more clever yeah it feels icky because it is alright let me right here this is hacky because because I was tired [Laughter] let's submit it like that oh let me remove this atleast we want to have formatted nicely code also the console.log we can't leave it like that okay so I guess I guess we can say leading zero will be the test if this like that but this leading zero will test if starts with a zero and then if leading zero and number is different than zero or or what or the length of an 8 leading zero oh I think I know but that's pretty is no matter what I didn't talk about if reading zero and end up flanked it should be a string right here and that rank is greater than one it has a leading zero and [Music] and that length is bigger than one but it can be reading zero no shouldn't be able zero one should be false I guess now we can test it there so I can remove that let's still see if that works okay and this go somewhere here Wow just convert to a number and check if it's equal to zero yes but 0 0 will be 0 converted to a number so we don't want that that was the main issue in the first place sorry so hike how can I put this here if they stand false if [Music] not this and and not yes this also looks icky let's see if it works I wanted the one line yeah look at that okay you try to figure out what I did here detonator turns already operate their time all right no way look at these rejects ding that's plate filter B equals 2 number 2 string and what be equals to number V the string and the number V is less than 260 if this path really he did it well this is really clever link the video on there get some kids yeah I should have to I should well I should I can't speak anymore I should have should have had that why are you watching me curled anyway all right now this is clever I wish I knew what he did I guess where is our regex man it would tell us what he did here are what's the time who in five minutes I kinda want to do more but I'm tired so I know let's see what's next this can go on forever the maximum sub subarrays problem consists in finding the maximum servo continuous sequence of sequence in an array what to the maximum and unlike this it's dynamic programming I should look into this should be it something fancy imple encryption take every second chart from the swing and the other chart that are not every second chart and can cut them as a new string uh okay do these end times Oh try again apparently did it and I see my solution let's see how I did it a but I did it why don't you want me to show my also I again if you have not solved this but again [Music] oh I think I just I started and I didn't finish a and too tired for this maybe some pointy all right I think that's it for today I got 750 subscribers today oh that's huge pink your first baby I hope that from now on we'll see more people like today in the live streams in the yesterday's livestream we got five people as interesting and only J was active dynamic programming means that you save the values of calculations and then you check to see if you have already calculated the value yeah I know the basic concept but they never never did something that when I played the code it was cold fight I saw some some solutions with dynamic programming they were like four level deeper ace J for special guests yeah I hope you enjoyed this I'm going to do more in the future I want as I said to the live streams and then eventually turn these live streams into standalone videos so for example if people are searching how to fail on code words they can only see a five-minute video not to our video also I want to do in these challenges something with HTML and CSS maybe build websites or applications the best one are you leaving I don't know am i my wife is sleeping for an hour now basically the problem set in the description whoa I need to go over the video candid someone did that for me go over the video and see which one oh but yeah it will be nice for for people to find that blam is through I am the plan LP LP don't make a right way while she's sleeping so she's always like going to sleep flowers faster and wakes up one hour later so she's like are you even sleeping or what Liam or lady Liam okay the lien like Lee someday I will pronounce your name right for your 9/8 see what they did that you're nine that's nothing but even in English English okay see what to bid like mr. Neeson from taken okay let's see do you have any suggestions about these series Diane English 9 exactly that's exactly how I pronounced it you're right Stephen at least mine does webcam chips chips I totally forgot I have a bag of chips that's my bag of chips I shouldn't eat chips it at midnight but polo and webcam yes I would like to get a green screen so that you won't see where I live but yeah should should do webcam I just wanted to for the pickup time series to finish by Jay thank you for being around I like hanging out with you guys on this card even if you want feel free to this to join us in discord or pretty fun people at least but well we are fun even it's not that fun but don't help him we are mad we're laughing at his jokes because you don't want to make him feel uncomfortable but you know but other than that we're pretty fun so you should join our discard right partial keys now this is annoying why didn't we declarative programming these bugs made between we didn't finish it what's the link let me give you the link all right to to to to to to I think from the next livestream I should always always I should also store my submissions and I could turn them into some Twitter post that will be nice for content and I should yeah put in the description the time I'm doing different challenges so it will be easier for people to find them uh yeah okay I was kidding about the bun he's funny hopefully you know that I was he has some cool dad jokes up net jokes all right I guess that's it I wish I could do more code words but I just feel that it will be pain even is in this car Hey look at that okay I think it'll stop now thank y'all for joining I'll see you tomorrow tomorrow I'm going to continue the freaking camp curriculum series I have let's see the three lessons and four five projects I think okay assuming it's so informations information security with helmet quality assurance with tests and testing which I advanced note and Express and then five projects which are pretty art ish because they need to well we need to write tests and everything but once we're done with this well that will be fun we can do whatever we want we're free all right thanks all for joining during the discord if you haven't we can discuss more there and let us see you tomorrow I
Info
Channel: Florin Pop
Views: 25,789
Rating: 4.9323306 out of 5
Keywords: learn programming, programming for beginners, live coding, live, live stream, programming tutorial, florin pop, coding, coding for beginners, coding tutorial, javascript, javascript tutorial, codewars, codewars javascript, javascript coding challenge, coding challenge, javascript challenge
Id: ZR2hs726h74
Channel Id: undefined
Length: 136min 7sec (8167 seconds)
Published: Wed Mar 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.