 Okay, so I made a Wordle on the command line. Basically how it works, it works just like regular Wordle. It takes a file, dictionary.txt, and it reads lines from it, and it does what Wordle would do on it. Let's see. Let's put never. That doesn't have anything. What about first? You have an S. You know what, this might take a while, because I'm not really that good at Wordle. So let me just delete everything here. And it's not just for five letter words. I'm going to use something like this Super Word, Broom, just the number three, and let's do eight. Okay, and no need to recompile anything. Yeah, I saved it. Five letters, so it's either Broom or eight. Let's run it again, 15, so this one is going to be super... Now a thing I could have implemented, but I didn't, was highlighting instead of making the words colored. I just didn't do it because I thought it looked ugly. But yeah, you could probably do that if you change something in this header file. What this header file basically does is it gives you colors. It makes a system call, and you know, I'm not too sure how it works. I saw it on some video, and I didn't, because I didn't feel like learning end-curses for this, that might have been too overcombed. Oh, also another thing I wish I could have implemented was that you see how right here this word is encoded, this is the one you entered, and then it returns this. What I wish I would have done is for it to rewrite on what you just written, but it's not really that important. Okay, so I'm going to go back to my long list of words. Okay. Now I'm going to go over the logic real quick. This is the basic stuff. Oh, yeah, another limitation. You see how the array only has 50 characters, so that means you can only do 50 character words, like maximum. You can always increase it in the code if you want to do something like quote sort of game, like, oh, I'm going to do a word for quotes of a movie or something. So yeah, this sets the file pointer, and it opens dictionary.txt in read mode. This gives a seed for the random number generator based on time. This is just an error message if dictionary.txt was not there. Let's see what would happen. Let's change the name of dictionary.txt. Let me close this real quick. Let's call it dictionary.txt and call it list.txt. Let's see what happens if I try to run. See, okay, so I could not find dictionary.txt. Now later, this counts all the words, all the lines in dictionary.txt, and if it doesn't have any lines, it returns the error empty file, so I'm going to make a dictionary.txt, but this time it has nothing in it. I'll run word or clone empty file. So yeah, now I'll change this later. Okay, so after that, so it uses the number of lines it got and used it as a modulo for the random number generator so you would only get a number from one to the amount of lines there are. That's why I had to add that one at the end because you can't have line zero. And then I reset the cursor in the file to zero, so it would go back to start because I think I'm pretty sure this affects where it goes, where the cursor goes. I'm not sure, but I just did that to be safe. This while loop, it reads through the file and it goes to the line that you set right here in read line and puts it in the first string, which is the secret word. Now this is where the game actually starts. It prompts you for your word size, and then asks you for the for loop. This ten right here is how many tries you have in the actual GitHub script. First of all, there are some little things that I changed because for previous attempts of recording this video, there's just some things that didn't make sense. Like for example, instead of doing plus one here, you could read line plus plus at the bottom because of some. Then it asks you for your guess. It gets it through fgets. It stores it in string two, which is the secret word. And then it goes through the main loop, which is the actual logic of the game. I'm going to try to explain it with Krita because this was actually a little bit embarrassing. It took me a while. Before I thought wordle, because I wasn't too familiar with wordle, I thought, well, I could just do two for loops and cycle through all the words inside. And if it's the same, but not in the same pointer, not in the same index, sorry, it would be yellow, but if it's in the same index, it'd be green. So I just did two for loops. Let's say for A and then for B. I assume that they're cycling through the indexes of the words. So first I would do something like string A. The character in STR is the same as the character in WRT at these indexes. And then later check if A is the same as B. That would give you green. If not, but this is still true, then you get yellow. And if not, then it would give you a gray. So it turns out I watched the video later after doing this on how wordle worked. And it turns out that's not how it worked. So for example, let's go to Broom, Broom, then Rooms. Okay, Room with three O's. So these two O's would be green, but this one O would be yellow because there's no extra O's left. This would also be green because it's in the same spot, this would be yellow. Anyways, so what I tried to do is, okay, I need that back, is let's say we got blue, we got yellow here, and then we find later on that there's a match with the same thing it found. So we should store like a little check that holds the index right here so that when it later finds a match in the same index it would work. It would go back and tell it, no, you're going to be gray now. And there was a lot of just complications and it's just not working. So I asked my dad for an opinion on this. I don't remember exactly what he said. This was a while ago, but I sort of dismissed this at first because he just did one for loop, so let's say four, it was just four I. And since both strings are supposed to be the same length, it doesn't matter. And it would check, since it's not a nested for loop, it would only check if they're in the same index. So this would only check for perfect. And I dismissed it at first thinking, oh well this is kind of dumb because I could have just done the other thing. That was an example of I think they called premature optimization because I realized, oh, this would actually be so much simpler because you get rid of the problem of having to recheck and make sure there was perfects before. Like if you get a yellow and then there's a perfect after, it fixes that problem because you get rid of perfects and you know you don't have it. So let's go back to that broom room example. So what would first happen is I would have to erase. It's like check as for string and check written for the written one. So it'd be check as check w. And so first it would go, okay, you got green here. You don't have green anywhere here. So you got green here. You got green here. You got green here. And then check s and check w would say, okay, so stop checking these. Check w would say stop checking these three letters and check s would say stop checking these three letters. And then it would go after, then you get to the second one which is a nested for loop. So I think the time complexity would be something like n squared because you have a nested for loop. So first it would check here. It would say, okay, nothing here. And then it finds something here and it's like, okay, you got a yellow here. Stop checking this and stop checking that. Then it goes here. There's nothing here. There's nothing left. So end it. This is gray. Hopefully you understood that logic. I know I'm going pretty quick here. So let's actually look at the code. So first here is the check. Oh, here's the common part. This is an integer variable. If you saw my last video, it was about this thing that I could store characters and checking if it was working or not. Not working or not. If it had a match or not. And basically what I found was I said in that video that I didn't need to use it. But then I later used it because not using it made stuff a little bit more clutter than I would like it to be. Okay, so first it would check if the string you wrote is the same size as the secret string. And if not, it will tell you wrong size. It returns false and you have to write it again. So that uses up one of your tries. Okay, next it would fill all of these integer arrays with zero. So all of these would be zero. After that, this is the part where it checks all the perfects. So it checks if they're the same letter at the same spot. If yes, it would turn into one instead of zero. It would put this at the... Oh, I have a little bit of an optimization here. So let's see. I'm going to pause the video and just implement it real quick. Okay, so I know it's a little pointless since it's just such a small program. It does it like the change is very noticeable. So what I did is like, oh, if it matches, if it's perfect, then just skip doing this check because it would use a lot of... It would use more compared to this. Again, n squared time complexity. Okay, so what it does here, because it actually does not skip, it does not skip, like I said, the ones that have already been checked. It checks if it has already been checked and then continues. So like right here, if check s equals zero and also equals zero, if both of them are not locked, then continue and you can change it here. It's not actually checking... Well, right here it is checking something, but it's not actually skipping it. It's not actually just not iterating through it. So yeah, and down here, that's the logic for turning the colors. Right here, the common one is gonna... If it's not the same character, I'd make it negative. I'd make it negative and then the number of the character. So then it would do red. I had to turn it back into the character. If it is perfect, it does the number of the character times two plus one. So that's what this module is for. It divides to the one. It gets rid of the extra one because it just does a bit shift. And it turns it green. If it's zero, which really should just be announced, if it's zero, then it divides by two, makes it yellow. Oh yeah, it should return back. Sorry. Okay. I think that's all. Sorry for getting close to the mic. I think that's all. Link to the code is in the GitHub. Again, it's not gonna look exactly like this. I just implemented this right now, so... Yeah, it's pretty... Tell me what you think. I'm not sure if it works on Windows because I've only tried it on Linux and I've only sent it to my friend who has Linux. So for any of you who are using Windows, try to get it to compile, see if it works or not. Okay, I think that's all.