Skip to content

Simple coding exercises

Notifications You must be signed in to change notification settings

jpenny1993/CodeChallenges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Code Challenges

Simple code exercises that any developer should be able to accomplish in 10-15 minutes.
These are my solutions to these exercises.

Anagram

Anagrams are words or phrases made by mixing up the letters of other words or phrases.
Write a method that detects if a string is an anagram of another.
Solution

Caesar cipher

The Caesar cipher is a basic encryption technique used by Julius Caesar to securely communicate with his generals.
Each letter is replaced by another letter N positions down the english alphabet.
For example, for a rotation of 5, the letter 'c' would be replaced by an 'h'.
In case of a 'z', the alphabet rotates and it is transformed into a 'd'.
Implement a decoder for the Caesar cipher where N = 4.
Solution

Fibonacci

Write a method that returns the nth element of the Fibonacci Sequence.
The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,...
The next number is found by adding up the two numbers before it.
Assume that indexes start at zero, e.g., fib(0) = 0, fib(1) = 1, ...
Solution

FizzBuzz

Write a method that returns 'Fizz' for multiples of three and 'Buzz' for the multiples of five.
For numbers which are multiples of both three and five return 'FizzBuzz'.
For numbers that are neither, return the input number.
Solution

Greatest common denominator

Write a method that finds the greatest common denominator of two integers, which are not all zero.
The gcd is the largest positive integer that divides each of the integers without a remainder.
For example, the gcd of 8 and 12 is 4.
Solution

Palindrome

A palindrome is a word which reads the same backward or forward. 'abcba' is a palindrome.
Write a method that detects if a string is a palindrome.
Solution

Prime numbers

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Write a method that checks if a number is prime number.
Solution

About

Simple coding exercises

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages