Live code: trying Codewars for the first time
Chapters8
The host introduces themselves, explains a pre recorded stream, and presents Code Wars tasks as the session’s focus.
Watching Coding in Public try Codewars live, Chris wanders through beginner puzzles, debugging in real-time and sharing honest missteps.
Summary
Chris from Coding in Public jumps into Codewars for the first time, documenting his first steps as a new user. He walks through a couple of kata live, muttering about how to count vowels, identify an outlier in an array, and sort words based on embedded numbers. The session is imperfect but refreshingly candid: he tests ideas, logs intermediate results, and admits when he’s unsure or makes small mistakes. He toggles between JavaScript and TypeScript notions, jokes about autocomplete, and demonstrates a practical, learn-as-you-go approach to problem solving. The video is as much about the learning process as it is about code: it offers a glimpse into how a beginner navigates unfamiliar algorithms, references common JS/TS methods, and contends with typical coding roadblocks. You’ll also hear him adjust plans on the fly, choose readability over premature optimization, and reflect on whether live coding helps or hinders progress. If you’re curious about Codewars from a fresh perspective, this stream provides a relatable, step-by-step exploration—warts and all.
Key Takeaways
- Starting Codewars as a complete beginner, Chris treats the first kata as a hands-on learning exercise, detailing how to count vowels by iterating through characters and using an includes-based check.
- For the outlier problem, he experiments with a two-step approach: determine whether the majority in the first three numbers is even or odd, then scan the rest of the array to identify the single number that doesn’t match.
- In the word-sorting kata, he attempts to extract the position digit from each word (via regex), builds a mapping, and finally joins the words in the correct order to form the result.
- He revises his plan on the fly, uses console.log to validate intermediate results, and openly questions whether there’s a more efficient solution, highlighting the value of live debugging.
- The session ends with a reflective closer: learning happens most when you try, fail, and explain your thought process aloud, making Codewars a practical playground for beginners seeking real-world problem-solving habits.
Who Is This For?
Essential viewing for developers who are new to Codewars or algorithm challenges, especially those who learn best by watching someone think aloud and work through puzzles in real time.
Notable Quotes
"Hey, what's up? My name is Chris and welcome to Coding in Public."
—Opening line where Chris introduces the channel and the session.
"return the number count of vowels given in a given string. A e i o u are vowels but not y."
—First kata idea as he reads the challenge prompt aloud.
"I think there's a better way to do that but… this will give me a check on all of them."
—Intent to optimize the outlier solution, acknowledging room for improvement.
"Always know your inputs. And that still didn't work."
—Frustration and debugging moment while tackling the sorting kata.
"Hopefully that was interesting. I haven’t done this kind of thing before."
—Close reflection on the experiment and encouragement to the audience.
Questions This Video Answers
- How do you count vowels efficiently in JavaScript without using regex?
- What’s a simple approach to find the single outlier in an array of odds or evens in Codewars?
- How can I extract and sort words by embedded digits in JavaScript using a regex?
- What are the benefits and drawbacks of live-coding practice for learning algorithms?
- What’s a beginner-friendly strategy for tackling Codewars katas step by step?
Full Transcript
Hey, what's up? My name is Chris and welcome to Coding in Public. Okay, so today I am not able to do a live stream, so I pre-recorded this ahead of time. You can see we've got the Christmas lights going and we're going to work through Code Wars, which I've never actually done before. And I literally just created an account. That's all I know so far. So, let's jump in together here. And here you can see I've got the Code Wars account up and going, and it gives me a task. That's the only thing I know so far.
So, uh, let's work through this together. Uh I see here we've got return the number count of vowels given in a given string. A e i o u are vowels but not y. Okay. Um so I'm guessing I just changed this. So whatever the string is let's just have a let like be like numbum of vowels. Uh let me know. Actually let me zoom in just a touch. Uh since this isn't live I already forgot. um you can't let me know anything. Uh let's start with zero here. Then I'm simply going to iterate on each of these items.
So I should be able to take the string dot actually let's just do this for um yeah const s of string. So we're going to loop through each of these items. I just want to see if it's one of these items. Um, so let's go ahead and also declare up here like uh vowels if I can type equals and we're going to say a, e, i, o, and u. Hopefully this music isn't too loud for you. It's just real subtle. That's the plan at least. Okay. So now I just want to ask if string is in that.
And if so, I'll add to the number. Otherwise, I'll just return or continue or whatever. Um, so yeah. So, I'll just say if and I'll say s sorry uh vowels.inccludes and then I'll pass in the s. Let's see if I can do all this without any autocomplete. Uh, then I want to take the number of vowels and I just want to add to it. Is that right? Probably not. Uh, five should be abracadabra. Let's see. Number of vowels equals vows plus one. All right. Uh, let's see. Let's console log inside here just to see what I'm getting.
So, this should be an individual item. Let's see if it actually lets me. Okay. So, AB. So it is logging it properly. Oh, I never returned. Okay, details. So now we're going to return the numbum of vows. And then maybe we did it correctly. Let's see. Yeah. Okay. I was like I I think that's right. Um I don't even know how to go to the next one. Attempt. I think I attempted it. Is there Did I zoom in too much to not see the next one? Skip. Next. How do I go to the next item here?
instructions. Uh, skip, unlock solutions, discuss, test, skip. Okay. All right. Let's zoom back in. I don't know. That probably wasn't the right way to do that. All right. You are given an array which will have a length of at least three, but could be very large containing integers. Um the array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer n. Okay. Um it's either all odd. Sorry, it's either entirely comprised of odd or entirely comprised of even except for a single. Okay. So there's just an opposite.
Write a method that takes the array as an argument and returns this outlier n. Okay. the only odd number. The only even number. Okay. So, I first need to determine if it's odd or even. Right now, it could be the any section in here. Um, so maybe I should think I'm sure there's like a super performant way to do this, and I'm sure I'm not going to do that. So, hopefully you can be okay with that. We're going to loop through each item, and all I want to see is basically um if there's odds or evens so far.
So, it could be at the first position or the second position, and that doesn't tell me enough. So, I need to at least leap like loop through the first three and see what they are. All right, so let's do this. Um, uh, we're going to say like, uh, is odd, I guess, or is even. How about that? I'm guessing zero. No, zero could be in there, too. So, we're going to say whatever the num is that I pass in, I wish this was JavaScript or TypeScript, but that's okay. We're going to say num modulo, wherever that is, uh, 2 equals zero.
Okay, so the first thing I'm going to do is [music] it's okay. Calm down. We're going to say console log is even just to make sure I didn't make some dumb error here. And we're going to console like this. And this should say true. Okay, cool. All right, so we've got our little is even function. Now, I want to loop through the first three items no matter what. So, that's the first thing I'm going to do. We're going to loop through all the items. And let's see, let's just do a for each or for loop, I guess.
Um, let's do a for each. So, I'm going to say integers for each. And I want to take each integer, and I also want to grab the index, which I probably could have named that better, but that's okay. And uh I want to make sure that I've looped through like each item and I check to see let's see how to say this loop. Yeah. So here we're going to have this like int sorry uh let and we'll call this like uh outlier equals and right now it will be we'll just declare it. We won't initialize it with anything.
Okay. So, I want to make sure that I loop through the first item or each item. And if it's less than index two, yeah, less than index three, then I loop through again, no matter what, because I need to double check that there's at least two that are the same. So, in other words, in the first three, if there's only three, it could be odd, even, and I don't know [music] which is the normal yet. And then odd tells me that the even is the even one out, if that makes sense. So, that's what we're going to do so far.
Um, how do I loop back to that? I don't really know. [snorts] So, my instinct is to have some kind of like array here. I don't really know how to do this. So, this is probably not a good way. But, let's just do it the not good way first. So we'll say like all right if we we're going to have like first three [clears throat] let's comment this out. Let's have like a first and initial loop that just looks at the first three. This seems really bad. Um let's just do it. We'll say like first three equals and we'll have integers uh jurers dot um slice oh man splice or slice I don't remember which one is splice a javascript is this the one that I think this is the one that is modifies the array so I want slice um so I want zero to two is that Right.
And let's console log this. I'm not like super great at these kinds of things, but I Oops. I feel like this is a great time or a way to test yourself because you have to do it live and doing it live like actually shows you expected undefined to equal one. Okay, it should give me to the second one. So, I went to the third one. Okay, cool. All right, so we get the first three. I just couldn't remember what that gave you back. Um, why can I not see the start of this? What is this search thing?
Can you not? Okay. Okay. So, what I want to do is loop through these first three. And I guess I'm just going to do this sloppy to start with. So, we first get the first three and figure out what norm is. All right. So I'm going to take integers or sorry first three dot for each we're going to take each item and we'll have like a let norm why not and again we won't initialize it with anything so all I want to say is if why am I having a hard time figuring this out? Okay, so let's let's think through the problem then.
So, first thing I want to do is check the first two, right? If the first two are both like odd or even, then I know what the odd one out is, right? If they're not, then I have to check the third one. Now, where do I store this exactly? I don't know. Um norm is like the thing I'm going to check against, I guess. Yeah. So, let's I guess just check this first. All right. So, I'm going to say if um I don't need a loop over these either. So I'm just going to say if um first three zero yeah let's say is even why do I keep doing that um this one if this equals the same as is They could both be false.
I think that could work. Yeah. All right. I think that works. We'll say first three uh one then I know that the norm if whatever the first one is. So first if this is is even I'll talk through this in a second then this would be the even. So I don't know exactly how to declare this. I guess I could just do zero or one. I just need to know which one I'm looking for when I go ahead and loop through everything. Um, so I could say like even, I guess, otherwise I'm looking for odd.
All right. So, let's first of all do this and see what happens. Um, and I want to console log the norm here, which I don't know if this one will give me anything. It doesn't yet. All right. It's undefined still. So, it doesn't hit this because they're not both the exact same. But if I were to change this, can I change this? and we run it again. Even. Okay, so that is working properly. Um, let's say that these are both odd and see if that works. Odd. Okay, so now I basically the the only other thing to check is if they're not the exact same.
So then I could say else I want to check to see if I need to check all the different variations. Yeah, I think so. So, let's change this to something like F just to make it a little more compressed. All right. Now, what I want to do is check to see if um there's probably a more efficient way to do this. Let's just say else if let's just do another if statement. if is even. We're going to grab the same thing and we'll take this and the second well the third item if that's the same then we'll do the exact same thing which makes me think there is a better way to do that but um all right so then they would be either even or odd that right f0 is equal to that missing parenthesis.
Okay. So, this should tell me even. All right. Otherwise, we'll just check to see if 0 1 and 02 are the same. Okay. So, we are going to get through this mangled mess. There's a way better way to do this, I'm sure. Um, let's just check all these at the same time. Um, if that is the same, let's just leave it messy right now. Okay, [snorts] like I said, I'm not very good at these problems, but there's one way to to actually test yourself, and it's not doing it by yourself in the dark. It's doing it live.
Um, even if it's a live recording. Okay, first three, figure out what. So, we now know if it's odd or even, which means we know what the outlier like should be the opposite, whatever. So, if the norm is even, then I'm looking for an odd number. Okay. So now what I'm going to do is come down here and we're going to say I guess kind of no matter why even if it's no pun intended like even if it's uh only three we can loop through those three again that's not a big deal. This won't be the most efficient thing I've ever done in my life but I'm just going to try to get the answer and call call it a day.
Okay integers. So for each integer what we're going to check to see is um we want to see if it's odd or even right? So I guess we could actually name this what if we called this true or false because then false oh wait norm is even this would be zero that's fine this would need to be one okay I think that works all right so now what I want to do is check to see if the individual item so we don't really need this index anymore either which means I'll probably return this to a for loop.
So we'll say for const I of uh integers to jur. All right. Uh we're simply going to ask if it is um the opposite right of whatever it's supposed to be. Yeah. So if the I is even if I is equal to whatever the norm is then I'll just continue right otherwise I'll return equals I I think that's it return outlier I'm [snorts] not sure if that's correct. Yep. Okay, cool. So, there's way a way more efficient way to do that. Let me talk through the logic at least. So, because we have to figure out what's the normal, is it even or odd?
I have to know the first three. Um, that's the only way to predictably know if like the normal two of them are even or two of them are odd or whatever. Um, so this will give me a check on all them. Like this tells me are these both even etc. Then I loop through each of these and I just simply ask if the individual item is the same as the norm. So this is going to be set to true if the whole thing is even or odd if the whole thing is odd. And then if it is, I just continue.
So go to the next loop. Um, and if it's not, then I return and jump straight out. So I'm sure this could be way faster. Like this seems way too long for I'm sure some of these could be really long. I don't know. Anyhow. Okay, cool. Well, uh, I think we figured it out enough. Skip this kata. See, how do I say like done? I did the thing. I don't know. Let's do a couple more. Your task is to sort a given string. Each word in the string will contain a single number. The number is the position the word should have had should have in the result.
Note, numbers can be from 1 to nine. So, one will be the first word, not zero. Okay. Uh the input is string is empty. Return an empty string. The words in the input string will only contain valid executive numbers. Okay. So there's a string here. This is a test. All right. I did not understand that. Your task is to sort even string. Each word in the string will contain a single number. Every word has a number in it. The number is a position position the word should have in the result. Okay. So this is saying it should be the last one.
This is the first one. And then I remove that number. Okay. Okay. So I need to order these things. mean how would I want to order this? I guess I would just push it in. So let's have like a final or something like that. And this is just could be [snorts] empty array. And then I'll look at each of the items, reax that thing out. Do I need to strip out the text? No, I don't. Okay. Um, yeah, I think so. I'm just going to say for const w of words. So, for each of these items, I'm just simply going to ask um why don't we make this thing an object like this?
Right. Can I just do this? Basically, that's what I'll do. And then say 1 2 3 4 whatever. And then output at the end. I feel like that could work. We could also Yeah, I I think that works. There's probably a way to do this just with the array itself. Like I could probably do a huge reduce off of this thing. Let's go for clarity. And no, I kind of want I like the idea of the reduce, but I think that will be too complex and it may be bad anyhow performance-wise. So, okay, let's just do it this way and we'll call it a day.
Um, so for each of the items, we need to first check to see what the number is in there. So, I don't remember how to do reax for a number off the top of my head because now I just use AI for that. That's like the one thing I will happily always use AI for. And I could not care less to have to remember reax. I mean, I can read it for the most part when I see it. Like, okay, yeah, I know what that does, but I don't want to have to write it. Um so I don't um so let's uh we'll say like uh position equals and then I just want to take the w dot test or find or I forget what the even the thing is regax to find a single number in a string.
Thank you. All right. This is just uh raycast. Yeah. Okay. There we go. So how do I test this thing again? [laughter] Um match. Duh. All right. So, we're going to say um [clears throat] match and then we'll I thought I did this thing so that I wouldn't have to remember. Um do I have to do like I should just do this? I was just trying to remember if I had to do like a string and then let's Yeah, I must have to do string. All right, let's console log the position. just see what I'm getting here.
No, no, no. Awesome. Um, [laughter] that works really well. Um, all right. So, let's go back to here and see what I did wrong. And you have to do like I, like I said, this is the one thing I will happily always push off. Uh, along what does the B and the B mean here? I just said I could read it. [laughter] Well, that's one way to call your bluff, you know. Um, all right. So, let's steal this whole thing. Let me copy that. Yeah. Okay. Let's try that. What am I messing up? Oh, I have to.
All right, let's take this dot uh split and we'll split it on an empty string. Okay, cool. And now let's do the position here. Always know your inputs. And that still didn't work. I don't understand why I wouldn't just need this. Oh, come on, Chris. Rejax 101. What I used to do back in the day. All right, we're going to find digit. Did I just do the wrong thing? Okay, let me get out of here. Isn't that literally what I just did? What am I not understanding here? This is literally what I'm doing, right? How do I copy this over?
Do I have to do the GM thing? I am getting this thing correct. Yeah. What am I missing here? Um, let's see. Search for single number reax JavaScript. Uh, this is annoyingly embarrassing. Is it just that I have it in strings? Come on, Chris. We did a thing. Okay. And I just want to pick off the the first item. We made that way too hard. So then we're [clears throat] just going to final um and we'll take the position. whatever that is and we'll add the word to it. Okay. And then down here we're going to return um let's see can I take object let's console.log um object valvalues and we're going to pass in the final here.
This is a test. Okay cool. And then I'm just going to join them on nothing. on an empty string like that. Okay, let's see if this works. So, we're going to return this here. Yeah. What? All reading a zero. What is it like? Is it this? Oh, there's an empty string. Okay, we'll say like then we're just going to return final. We're just going to overwrite It's probably could be better, but we'll just do that. And then we'll say if final, this is not the right way to yeah, we'll just say if if final equals an empty string, then we'll just return an empty string.
Otherwise, we'll return that reading zero. So, it won't even let me do this. Can I do this? So, we say undefined. We're trying to split off this. All right, let's let's get out of here. Actually, I think this could still work. That's There's definitely a better way to do that, but we'll just say like um if W equals an empty string, then we want to return this here. Oops. I think that works. It's not the most elegant solution, but assuming I did that right. Yeah. Okay. So, we'll just return early basically and then Yeah, I don't there's Yeah, there may be a better way to like insert these indices in like different places, but I don't know.
I think this is fine. Okay, next. Or skip, I guess, cuz I already attempted. We'll do maybe one more. Um, hopefully you enjoyed this. Hopefully you did better than I did. In a small town with population P 0 equals 10,000 at the beginning of the year, the population regularly increases by 2% per year and more over 50 new inhabitants per year come to live in the town. How many years does the town need to see its population this is just math see its population greater than or equal to P equals 1,200 inhabitants. Oh okay. Okay.
So it can be given any I need three entire years. Okay. So it needs at least three years. Why? P 0 at the beginning is population zero. It always starts at a th00and end of the second year. And number of entire years a population greater or equal to population p August is an uh integer percent of positive or null floating value. Okay. Okay, so I can add in whatever item here and I should get out the number of years. Present the percent parameter as the percentage in the body of your function. there are no fractions.
The people at the end of the year, the population count is an integer. Round down. Okay. Okay. Okay. So, I think I understand this um as a whole um math is definitely not my strong suit, but we'll see what we can do. So, every year when we loop through the percentage, what is AUG again? I forget. It's an integer. Percentage percent of positive null or floating Okay. positive integers. P 0 and P are positive integers. A positive or null floating number. All right. So, we're going to get a certain value and every year which is the I mean I can't remember I have to keep looking at what these things are.
P population equal to or surpass inhabitants. Okay, so we're going to have number of years. So let's start with that at least because I know we're going to need that. Let num of years and we're going to say this is equal to zero for now. And then eventually we want to return the num of years. Right now it's all the stuff in the middle that matters. So the first thing I need to do is we add then we multiply times two plus 50 50 right 2% per year and more over 50 new inhabitants come per year.
Okay so we're going to first of all like do at least three years worth. So, [snorts] um I guess do I just like do that to start with? So, I'm going to take to start with we're going to take the P 0 plus 150 because this is three years. Oh, I can't really do that though. Okay, so first of all, we're going to um the P is the Man, I keep I don't like how small this thing is. B is percentage. Let me just write this thing out since I can't remember it. Uh P 0 is start uh percentage is like growth percentage I think whatever that happens to be.
Then we have the August the August the AUG inhabitants coming. Oh okay that's right. So they were just giving the original example. Okay. Um per year and then population to equal or surpass. Okay. Pop to equal. Um coming for your the growth rate itself. Okay. So what we're going to do is start with taking our existing population. Um, we're also going to have like let current pop equals whatever the P 0 is to start with, right? Like so much of these problems is just figuring out what they're asking and then once you do like the process itself is the job.
Like yeah, obviously after you figure out what like what they're asking and the structure of it, it's not hard to do, but um I don't know. I think I need to remember to be patient with myself and like learning what the thing is about because that's kind of the whole point of doing this, especially uh trying to do it kind of live. Um, all right. P 0 start. So, we're going to take this. We're going to add to P 0 P 0 times whatever the uh percentage is. Then we're going to add and because B mass this should be fine August right so we're going to do this this will take the current pop is equal to that okay now we should do the same thing here um this should just be the current pop right and then I can repeat this three times like this is obviously not right but let's just do this for now.
So this at least at least gives me whatever the current population is. So we'll say console.log the current pop. Okay. So I have this value. Now I just have to say like let's also and what was the other thing called? P. This is the population is supposed to surpass. Okay. 5,000. So it definitely has done that by this point. Why is it saying Oh, I think in the example they were just saying in that particular one it took three years. I was thinking it will need three entire years. Okay. Sorry, I'm an idiot. [laughter] Uh, so now what we're going to do is just check to see if this is the case.
Um, all right. So, let's just use like a while loop, I guess, which I've never really used in a program. It doesn't usually help. If it's uh less than the P, then we're going to current pop. If this is less than the P, then I just do this again. I guess I need to do this at first to start with. So, our current could it ever be already bigger? No. Okay. So, yeah. So, we're going to say current pop equals this. And then I'll just ask if current pop is less than P, then basically do this exact same thing again, right?
And then in the end, we're just going to return the number of years. Now, this percentage, now I got to round down, right? What was that again? Don't forget to convert the percentage parameter as a percentage in the body. So if you have two Okay. Um how do I do that? Um I I guess I is this right? 2.5 * 0.1, right? 2 * 0.1 should be that. That's right. No, it's Yeah, times 10. Like I said, I'm not very good at math as you can tell. There we go. Yeah, cuz it's 100th. Okay, duh.
Cuz it's a percentage. [laughter] Sorry, kids. Do your math when you're young. Um, okay. So, I think we should be good there. And then the last thing is I need to floor this. Math.f floor. And we're going to do all of this here. I think that works. Um, let's take this and just make it a little uh little helper here. new pop equals. We're just going to do all that. And then we can just run this new pop right here. It's just equal to whatever the new pop is. And we'll do the same thing here.
Okay, that works. uh return number of years. I think I deleted that. Um okay. So then outside of here, this is after the while loop should be done column for a second. All right. Um now I want to take the number of years it takes. So while I'm in here, I should probably have let's see uh numbum. Let's start this at one, I guess. Yeah, I'll do it in here. So it starts with a single year and this accounts for this right here. Then we'll say num of years uh plus+ expected 20 to equal 15.
Let's see what I'm doing wrong. New uh num of years. And let's also console log the current pop two and the current year is that. Okay. So, something is wrong with my math then. [snorts] Surprise. All right. So, we've got P 0. Nope. [laughter] We found it. Current pop. Um, there we go. All right, that was it. that was a good little challenge. Um, it's probably again a more efficient way to do a lot of these. I'm not really super concerned about that. Um, I don't know how to do the next one by just clicking next.
So, let's try that. I don't know. Let's do one more. Um, okay. Take two strings, string one and string two, including only letters from A to Z. return a new sorted string alphabetical ascending and long as possible containing me and I know there's like an algorithm for this that I do not know um I yeah not having a CS background that's something I've really long wanted to get into but never really taken the time to do and most of my stuff is like not that performance intensive so it doesn't super matter and if it does I know I need to look it up and then I figure it out once and then I never have to touch it again so um so I'm going to do something really bad performance-wise so you should not do what I do but take two strings string one and string return a new sorted string alphabetically ascending the longest possible containing distinct letters each taken only once.
Okay. Well, I should have read the whole thing because I don't think that will be that hard. So, we have two strings. Do they both always It looks like they all contain something. They don't actually say that here, but they like they're not empty strings. So, I think what I'm going to do is just do a new set. All right. Am I missing this? S1 and S2 dot sort. No. Okay. Um. Uh. Oh, I need to spread these in equal to. Okay, let's at least get this and see what I'm getting because it may just have this wrong here.
So, let's console.log. Okay. So, I'm getting those items. Oh, and then I just need to um like join them. Yeah, I so I just didn't join. All right. Happy holidays. Okay. Well, hopefully that was interesting. Uh it was kind of fun to be able to play around with um this. I haven't done this kind of thing before. Let me know if you like these kinds of challenges. Um I hope that as you're watching, you're like, "Oh, you should do this and you should do this." and like take the time to pause and actually try it yourself.
Um, I cannot tell you how much live streaming has helped me realize like I don't know what I think I know. Um, or I don't know how to explain what I think I know how to explain. So, uh, I think you'll find the same thing and it should be really helpful to you, too. All right. Well, thanks much. Happy holidays. Peace out. See you next time. Thanks for watching. Happy coding.
More from Coding in Public
Get daily recaps from
Coding in Public
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.









