# Daily Coding Puzzles

### Ali Spittel ・2 min read

I think a lot of people know this at this point, but I love writing code. To wake myself up in the morning and get my brain running, I normally solve a code puzzle first thing when I get to work.

I normally find these on Project Euler, CodeWars, or HackerRank -- though I'm totally open to suggestions if anybody has a really good alternate resource! I really love the problem-solving nature of these code challenges, and how I can sometimes can come up with really cool out of the box solutions to them. I do feel like they help me become a stronger programmer, and an added bonus is that if I am interviewing at the time a lot of interview questions are similar to these (for better or for worse).

Since I'm already doing these every day, I thought it would be really cool to share my results on social media to keep me accountable and to see how other people solve the same problem. I normally solve these challenges in Python or JavaScript, but other people have been posting in Ruby, Rust, Ramda, and Clojure so far (which is so cool to see!). Some of them I have solved before at some point, so I post multiple answers in different languages or my refactors!

If you would like to follow along and post your own solutions (or just see other people's), follow me on Twitter or I've been using the hashtag #CodingPuzzle on them, so you could follow there instead! I normally post in between 8 and 9 AM EST since that is normally when I get to work! It's also led to some interesting discussions on efficiency and the strengths of different programming languages for solving these types of problems! These problems are also a variety of difficulties, so if one day's problem is too hard, still follow the next day for a new one!

To get started, today's problem was Project Euler Problem 2: Even Fibonacci Numbers: Each new term in the Fibonacci sequence is generated by adding the previous two terms. Find the sum of the even-valued terms. Please post your answer here!

Ali Spittel 💁@aspittel#CodingPuzzle day 4: Even Fibonacci Numbers

Each new term in the Fibonacci sequence is generated by adding the previous two terms. find the sum of the even-valued terms.

projecteuler.net/problem=212:13 PM - 10 Jul 2018

If you want to catch up on the previous ones, they were:

Ali Spittel 💁@aspittel#CodingPuzzle day 3:

Stop gninnipS My sdroW!

Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed.

From codewars.com/kata/stop-gnin…13:00 PM - 09 Jul 2018

Ali Spittel 💁@aspittel#CodingPuzzle day 2: Stacks: Balanced Brackets

Given strings of brackets, determine whether each sequence of brackets is balanced. If a string is balanced, print YES on a new line; otherwise, print NO on a new line.

hackerrank.com/challenges/ctc…12:30 PM - 06 Jul 2018

Ali Spittel 💁@aspittel#CodingPuzzle day 1: Simple Pig Latin

"Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched."

From codewars.com/kata/simple-pi…12:31 PM - 05 Jul 2018

Hope to see your answers!

Day 4Okay, just pipe the number of even terms you want into STDIN (an input of 4 will display the sum of the first 4

eventerms of fibonacci) and you're good to go.Befunge 93:

Kind of disappointed as this solution uses get and put and therefore is less... "fungical"? but trying to do this all on a single stack got away from me.

A Funge++ solution might look more elegant...

Here we go, MUCH happier with this Funge++ solution:

Just to show, Day 3 in C, Time: O(n), Space: O(1), the result is processed in place. Of course,

this oneonly works with ASCII…Quick subquiz for anyone actually reading this: under what circumstances will this program crash or exhibit undefined behaviour?

Awesome, thanks for sharing. 😁 If you have any interest in learning about bioinformatics (genetics, DNA, inheritance, and the data analysis surrounding it) rosalind.info is a really good site with quite a few puzzles!

These are awesome! Definitely adding them to the rotation

Awesome !

Unfortunately I don't have twitter.. but here are my answers:

Day 1Day 2Pretty sure it can be waaaay better

Day 3Day 4Day 4 (Project Euler #2) has been already proposed by @peter : dev.to/peter/project-euler-2---eve...

I gave my answer there 🙂

Others here have proposed pretty good solutions for the other three, but my answer to the fourth problem is distinctively different IMO.

## Day 1

Time: O(n), Space: O(n)

## Day 2

Time: O(n), Space: O(n)

## Day 3

Time: O(n), Space: O(n)

## Day 4

Time: O(n), Space: O(1)

Nice exercise, this also shows how clumsy JS is when dealing with string data. Everything has to be converted to and from arrays. And these exercises do not work with non-BMP Unicode characters, but that was not in the requirement ;)

Thanks for this, Ali. Another source of good programming puzzles is the Daily Programmer subreddit . The tasks are categorized as easy, intermediate and hard and there is a good discussion on how the solutions can be improved.

It's only JS and really hacky, but I've come to like alf.nu.

Oh awesome! Definitely adding those to the rotation -- I like the RegEx series because I don't like writing them so I should get more practice in!

You can try this one:

codingame.com/servlet/urlinvite?u=...

Add me as a friend!!