/SwiftAlgorithms

Swift Algorithms made in Playgrounds

Primary LanguageSwift

SwiftAlgorithms

Swift String Algorithms made in Playgrounds

##Reverse String ####You are to create a function that returns the string backwards. Ex:

  • Input: "Potato"
  • Output: "otatoP"

##PigLatin You are to create a function that returns a string in PigLatin language. Rules:

  • If a word begins with a consonant, move this consonant to the end of the word and add "ay" in the end. Ex: "happy" -> "appyay"
  • If a word begins with a vowel, add "way" in the end. Ex: "another" -> "anotherway"

##Palindrome Strings You are to create a function that checks if a string is a palindrome. Definition: "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward."

  • Input: "Go hang a salami, I'm a lasagna hog" - "Go hang a salami, I'm a lasagna hog"
  • Output: true
  • Input: "I like Swift" -> "tfiwS ekil I"
  • Output: false

##Reverse Word You are to create a function that returns the sentence backwards, reversing the words in the string. Ex:

  • Input: "The Boy is ten years old"
  • Output: "old years ten is Boy The"