Home Blog Pages Sprint-4 Tech

Problem solving

Tell your non-tech friend a story about a time you: Got blocked on a simple problem & solved a problem in an elegant way.

The problem was the Fizz Buzz challenge. It requires a function that takes an array of numbers. Then once the function is run it should return that array of numbers. But for every number that is a multiple of 3 it should return "Fizz" instead of that number. For every number that is a multiple of 5, it should return "Buzz" instead of that number. For every number divisible by both 3 & 5 it should return "Fizzbuzz" instead of the number. If none of those rules are applicable to the number in the array then it just returns the number. For example the returned array should be someting like 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizzbuzz ... and so on.

In one part of coding the Fizz Buzz / SuperFizzBuzz Kata challenge I started my line of code for the function with a line that saved writing it out a slightly longer way without really realising until it was pointed out. I used 15 instead of a statement mentioning 3 && 5 for the Fizzbuzz rule. I found the challenge difficult, although I could make total sense of it in my head, it was a great learning challenge.

I have learnt that there are so many ways you can code something and achieve the same result. However there are some that are far more efficient and take up a lot less time! I also learnt that I need to practice this one more and really understand the code and functions & loops etc. Although I got it to pass eventually It was a lot to remember and a totally new challenge. PRACTICE PRACTICE PRACTICE.

One simple problem I got blocked on for a while was a function of mine wouldn't pass. Prior to writing the function ruleset I just wanted to pass it as a correctly coded function. I had written it out correctly and even a friend had tested it and it was working. I was a bit stumped. I was then informed of a missing curly bracket. So bascially it was incorporating all of the above code in the function which rendered it useless. I used console to check this and reached out on slack for a second pair of eyes. This was greatly helpful and it was yet another reminder that very often an error can be down to an incorrect use of or missing syntax.

Reflections on using problem solving techniques and process:

Pseudocode

Pseudocode can be super helpful, and it's a welcome break from looking at a blank block in the code and not even knowing where to start. Some problems or errors contain many elements in which the only way to solve it is to break them down one by one, especially as a beginner! Writing it in pseudocode helps see it in plain english and then you can work on finding the right code method to solve the issue, hopefully without too much stress!

Trying something

Some of the problems make total sense when you read through them but then you can get totally stumped on how to code it. This is all part of the learning process. Giving it a go even in these situations can be much more helpful than it seems at the time when. I'll always give it a go, this certainly doesn't mean I will get it though! This is how we learn though, by trying as much as we can and then debugging to figure out what needs adjusting in our code.

Rubber ducky method

Sadly I do not have a rubber duck, but I did explain a method to a family member which I was finding difficult to code and it reinforced the learning around that problem. A great way to learn is to teach what you are trying to figure out. Using Slack to communicate with fellow students and help each other out has been great. Or tell someone or a rubber duck about your coding problem. This will help solidify what you are learning as you have to break it down yourself and convey it to someone else.

Reading error messages

I feel reasonably confident in reading error messages, but sometimes another method is then needed to figure out how to input what is required, or if the error message doesn't really give you much to go on you will need to do some digging or even ask another someone with a fresh set of eyes to scan over your code.

Console.logging

I feel pretty confident in console.logging it can help test a function you have written and you can see what comes back. either your function will work and return the desired result or message or you will get an error mesage and know something needs adjusting.

Googling

Google is great! It can sometimes be a blessing and a curse as you may be given so many results and none of them are exactly what you are looking for and you can end up down an endless rabbit hole. but with a bit of searching and keyword refinement it can be super helpful for a lot of cases! Also youtube to be able to see someone doing it and breaking it down at the same time. Just reading a block of random code with no explanation isn't very helpful if you don't understand it.

Asking peers for help

This is super helpful when you feel completely stuck and google can't save you. I would say this is the most useful method for problem solving if you are really stuck. Sometimes someone spotting something you missed or explaining it in a slightly different way helps it to click for you!

Asking coaches for help

Up until the Kata challenges I have managed fine, the first ones were fine but from FizzBuzz onwards It got a lot harder especially as it was the first time doing anything like these challenges. Reaching out on Slack as previously mentioned is great. There are definitely some things I want to break down with my facilitator to ensure I understand them completely.

Improving your process with reflection

I think reflection is very helpful and it helps to break it all down in plain english to yourself and whoever may be reading it. It's a way of making sure you still understand something you have been going over. I am going to create a list of some things I wish to dive into more in order to fully understand them.

books