• The game interface

Question related to mission Fizz Buzz

 

Long and boring story short I ended up finding Checkio as a game and challenge to help my learning as in a year I feel my progress has been moving slowly!

So the code for Fizz Buzz wasn't that hard, my method of attack was to open a separate editor (offline) and write the code to get an idea what needs to be done - and get something that runs as I want.

Did it in about 5 mins....but....it took me a while to figure out the method of getting my code to interact with the game interface.

Now I feel silly as it was really simple, but I was over thinking it...I wasn't expecting the game to handle things afterwards (eg checking the script)

I originally wrote my script to take user input then the int number was processed from there. The game obviously didn't want it like that, so my next attempt was to put the numbers being checked into the script...then things got a bit stressful

When looking at the hints, my first attempt at the code was almost bang on - using if and else statements with % but I hadn't grasped the concept of keeping it all in the checkio(number) function with the number argument...and just letting the game handle that side of things

I left it a few days and it was bugging me, so I came back with a fresh mind and boom - I opened my editor and wrote my code inside a function Exactly the same as the Games function using number as an argument..and it ran! I then could just type: checkio(15) or any number and test it out.

I have actually learned a bit about functions from this level - even though I got the if, else and division side of things pretty quickly, I hadn't used a function like this before (embarrassing I know)

I was buzzing when I wrote it all out offline as a function....ran the code, then using the shell fired little tasks into the function I made - for example: checkio(15) or checkio("any_integer")

It is surprising how little I actually know - the things I was learning by my own were all good but not really useful in real-life situations or a job environment, i have found that going back to basics has been an amazing experience because I used to skip over the 'boring' stuff like doing a hundred different things with strings - I just wanted to play Pygames etc - Now I love stuff like this!

Awesome game so far - had a look at the next mission and Im not too good at maths so I hope it isn't as bad as it looks!