Skip to content

Instantly share code, notes, and snippets.

View dimatarelkin's full-sized avatar

Dmitriy dimatarelkin

View GitHub Profile
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 {
//returns Fibonacci member by number - n
func fib(_ n: Int) -> Int {
return n < 2 ? n : (fib(n-1) + fib(n-2))
}
@dimatarelkin
dimatarelkin / Bubble sort
Last active October 2, 2018 15:51
Bubble, Merge & Quick sorts
//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 {