Programming Puzzles

There are a lot of aspects of computer programming, but it is very hard to compare two programmers. One might be amazing in one area and bad in most areas, but another may be average in all areas. In an interview to find a new programmer, that programmer can only demonstrate his or her expertise in the areas the interview will cover, which will be a tiny subset of everything a programmer could face in their day-to-day life. Being able to determine the approach a programmer takes can help determine which programmer is the best fit for a position. Programming puzzles can be used to put a programmer in an unfamiliar environment and watch their approach to solve the problem.

There are a few different websites that have programming problems. Project Euler is a website full of math problems that can be solved using programming. For example, the first problem on Project Euler is to find the sum of all multiple of three and five that are less than 1000. This would take a long time to solve by hand, but it can be solved in just seven lines of code. For those who are curious, the answer is 233,168. The twentieth problem requires you to find the sum of all the numbers in 100 factorial. This problem has two parts. The first is calculating 100 factorial, the product of all numbers between one and 100. This part is hard by hand, since it is 100 multiplications that end up resulting in a 156 number long number. However, it is very easy with programming, requiring just three lines of code. Calculating the sum of this number is easier by hand than programming, though. When you look at the number, it is very easy to just add together each number. In programming, it is not that easy. Internally, the computer stores the number in binary, a number system made up of ones and zeroes. Before we can add the numbers of the factorial, we must determine a way to translate that binary number into a decimal number, then extract individual numbers to add together.

Another website that can be used to practice problems that are more explicitly programming related is Code Signal. This website has a greater focus on programming than problem-solving. Programming can be done in a few ways, but some are better than others. The naïve approach to solve a problem in programming uses brute force to find the solution. This takes a lot of time to find the solution in some cases. Dynamic programming can be used to find the solution faster by reusing past work. For example, in a recent programming assessment I took, I had to find the solutions to a set of similar problems within a strict time limit of two seconds. Using the naïve approach, I was able to solve a couple thousand problems in that time limit, but the assessment required me to be able to solve hundreds of thousands in that time limit. I was able to implement dynamic programming to be able to solve 100,000 of these problems within two seconds, but I was not able to optimize my code well enough to solve 200,000 in two seconds. Working on more of these programming puzzles should enable me to solve problems like these more easily and reliably in the future.

Comments

Popular posts from this blog

How to Choose a Good Camp Site

Adventures Around Ada

Finishing Jeep Projects