 Hey everyone, welcome back to some more Python programming videos We're on the Python challenge now. We're looking at challenge number 10 We're on a bull dot html and we are presented with this picture of a bull and the only hint that we get here is Len of a 30 equals question mark. Okay. Um, I would think that that is Python code considering the Len function we'll get the length of something and a Must be a list because it's being indexed at the 30th position And it wants to know what that is I guess at least that's what I would assume Let's do some investigation. Let's view the source here. Check it out The title of the page is what are you looking at? I guess to match our little a little bull here and Looks like we just got a typical picture the bull JPEG using a map like we had beforehand with the B or B zip challenge and There is Coordinates for being clicked on here. So let's click it. Yep. If I move over the bull my cursor changes to a clicking thing I Just I guess it just means that I can click here because I can't anywhere else in the picture So it'll take me to sequence dot text. You can see down the bottom right, sorry bottom left and Huh a equals an array One But the array is incomplete the list Does not continue Obviously if I view the page source here, it's just a simple text file. So we're not gonna get anywhere What is the pattern here one? I would assume that okay since it's asking us to find the length of a being this sequence right because this is a equals all this wants the 30th Term in the sequence and I should find the length of it but Don't know how to continue this series. It's not like it's counting. It's not like it's adding the ones to it I'm zooming one 1121 1211 111,000 221 I don't know One two one one two two ones are What if like okay it adds it gets to a tense place And then it brings it carries one over here No, that doesn't work because I don't know what to do to get to the next step a equals one one two ones One two one one one one two two ones Wait a sec this index being one one Written out one one right here, and you say two ones Two and one being the next index and then one two One two and one one being said here and then one one one two two ones I don't know all right I'm just gonna Do some research copy this your new tab Oh All right, Wikipedia to the rescue Don't want to donate right now sorry guys Mathematics to look and say sequence is the sequence of integers beginning as follows one eleven twenty one Okay, so this is the same sequence we were looking at over here in our sequence Look and say sequence To generate a member of the sequence from the previous member read off the digits of the previous member counting the number of digits in the same digit So one is read off as one one One one is read off as two ones or two one and two one is read off as one two then one one or one two That's exactly what we just did that. That's it. That's sweet. Okay, and One two one one is what office one one then one two and two ones or one one two two one one So that's exactly What we've got here and just continues in that pattern Like looking at it and saying what it is the look and say sequence That's cool Look and say sequence was introduced and analyzed by John Conway. Dude. He's a cool guy. He made like the game of life and everything He's a cool dude. All right. Yeah. Yeah, he had the game of life. All right, let's How do we Let's say we start with just one This Start with a string of one because I'm not gonna use engines because I can't like add things to that and we're gonna want to loop through it, right? So Start because eventually we're gonna add more stuff to this. So let's say we're looking at Actually what we're gonna be looking at previously because we want to keep track of what we've just last seen in the loop, right? Let's say if we move on to If we go to one and one one if we start at one and then let's say, okay, we're looking through it We look through it. We say The count we're gonna keep count of what we've seen it's gonna be and then you say count and the number that you're looking at So one one now when we look through this one, it's gonna say count is gonna say Okay, we found one one and now we found two ones. So the next term is gonna be two Once so we keep track of account and what we've been looking at previously because in this case is gonna be one two and then one one right, so Got a count of one one and a count of one two and a count of two ones one one two Two ones So is that was that our next term? Yeah, it was One one two two one. Okay. So if we got a looking at previously variable, I'll just set that to be Right now the start of it Count is gonna start at zero and then next term We're gonna fill but right now it's gonna be an empty string So four term in start if term is what we were looking at previously And we'll add to our count variable count plus equals one If it's not Then We'll reset the count. We'll say it's back at one Not at zero, but at one because if we move on to something else We obviously are going to have one count of it to begin with right? That's why we're using count as one not count of zero up here and We can update our next term So plus equals as if we have multiple things like multiple different numbers or digits in the Term we want to keep track of every single one of them. So that's why we're gonna keep Keep it relative addition relative assignment and gonna change our count variable into a string And the way we would read it like we had earlier we would say okay There are two ones so count comes first and then we were actually looking at so count plus Looking at previously Now every time the loop Want to say looking at previously is gonna become what we were just looking at the term and then we can print out Next term if I run this Okay Next term is nothing for term and start if term is looking at previously which is count plus equals one So we're adding one and we're going to the next term. Oh, we're not even adding it to the first term we're not even adding to next term if Our start is only equal to one. Oh, so we have to do it at the end too, right? Like in this case We look through it Okay, looking the term is equal to looking at previously. So this runs this executes count plus equals one, but the Code block to actually change the next term is not being run So We should do it at the very end of the loop as well Demonstration I'm talking now if I run this hey, we get one one Now if we start at one one we get to one works We started to one One two one one that works just fine for us and one two one one Now we get the exact same sequence that we would have had in our in the sequence here Okay, cool But now we need to Do this over and over again you make it recursive Yeah, let's try and make this a function Define look and say With a start all this can be indented and we'll return a Next term and that as well and now if we print and say We start And I get one one now. We want to do this Oh, I'm super zoomed in on the bull We want to do this 30 times it says so for I in range Learn to type 30 What we'll do We'll say let's make a recursive start equals Look and say start So it's gonna keep what's gonna pass in one four Because that's the first start in this function and then it's gonna be your turn one one and then it's gonna do it again Get to one Pass in to one get one two one one do it again and again and again, so it's like oh This loop is doing it all for us. So now we can print out start. Oh Oh And there it is all right copy and paste this oh No, because it wanted the length of this right? Yeah, length of a 30 so Print out the length and we get this number 5,808 Maybe this is it When do our URL up here? Change bowl to 5,808 Hey, all right. We got it awesome Okay, that's pretty cool The look and say sequence Thanks Wikipedia Thanks Wikipedia for explaining how this works and trying to think through it That's the beauty of programming here. Now. We're on the 11th challenge guys sweet Sick nasty all right Let's uh Let's end the video now. I think I mean we accomplished the goal and got to the next challenge And we'll have to try this one in the next tutorial, but thank you guys for watching Hope you enjoyed this and I'll see you in the next tutorial