/Coding-Challenges

Various Coding Challenges in Swift

Coding-Challenges

Week 2

Week 2: Fizzbuzz Coding Challenge

Write a short program that prints each number from 1 to 100 on a new line.

For each multiple of 3, print "Fizz" instead of the number.

For each multiple of 5, print "Buzz" instead of the number.

For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.

Week 2: I Before E "I before E except after C" is perhaps the most famous English spelling rule. For the purpose of this challenge, the rule says:

if "ei" appears in a word, it must immediately follow "c".

If "ie" appears in a word, it must not immediately follow "c".

A word also follows the rule if neither "ei" nor "ie" appears anywhere in the word. Examples of words that follow this rule are:

fiery hierarchy hieroglyphic ceiling inconceivable receipt daily programmer one two three

There are many exceptions that don't follow this rule, but we will ignore exceptions in this case.

Coding Challenge Write a function that tells you whether or not a given word follows the "I before E except after C" rule.

check("a") => true check("zombie") => true check("transceiver") => true check("veil") => false check("icier") => false

Week 3

Week 3: Write a function that takes an array of strings and prints them, one per line, in a rectangular frame. For example the list ["This", "is", "a", "frame", "print"] gets printed as:


  • This *
  • is *
  • a *
  • frame *
  • print *

Week 4

Week 4: Fibonacci Write a function that computes the list of the first 100 Fibonacci numbers. The first two Fibonacci numbers are 1 and 1.

The n+1-st Fibonacci number can be computed by adding the n-th and the n-1-th Fibonacci number. The first few are therefore 1, 1, 1+1=2, 1+2=3, 2+3=5, 3+5=8.

Week 5

Week 5: Create a function that takes a String as a parameter.

Return the sum of any integers that are in the string.

Example:

Given "GH2U87A" you would return the value 17.

If there are no numbers in the string return 0.