This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let digitNames = [ | |
0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four", | |
5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine" | |
] | |
let numbers = [124] | |
let strings = numbers.map { (number) -> String in | |
var number = number | |
var output = "" | |
repeat { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//returns Fibonacci member by number - n | |
func fib(_ n: Int) -> Int { | |
return n < 2 ? n : (fib(n-1) + fib(n-2)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bubble sort | |
func bubbleSort (unsortedArray array: [Int]) -> [Int] { | |
var iteration = 0 | |
var newArray = array | |
while iteration < newArray.count - 1 { | |
var i = 0 | |
while i < newArray.count - 1 { |