Social icons:
<div style="
display: flex;
flex-direction: row;
justify-content: center;
align-items: center"
>
<a href="https://twitter.com/jelledio">
Social icons:
<div style="
display: flex;
flex-direction: row;
justify-content: center;
align-items: center"
>
<a href="https://twitter.com/jelledio">
/*Algorithm spec: | |
Given a long list of numbers: | |
let numbers = 1...1000000 | |
Write a function that transforms the list of numbers to strings with the following mapping and put it into a variable called results. | |
1->A, 2->B, 3->C ... 10->A0, 11->AA, 12->AB etc. | |
With the results from the last part, write a function that adds the following elements. |
func sumAll(objs: Any...) -> Int { | |
var sum = 0 | |
for obj in objs { | |
if obj is Int { | |
sum += obj as! Int | |
} else if obj is String { | |
if let variable = Int(obj as! String) { | |
sum += variable | |
} | |
} |
//When it says Any type, this means that we're dealing with generics | |
func swap<G>(item_1: inout G, item_2: inout G) { | |
let temp = item_1 | |
item_1 = item_2 | |
item_2 = temp | |
} | |
var one = "1" | |
var two = "2" |
let events: [String] = ["7:00 AM Hit the gym with Alex", "8:30 AM Coffee with Sarah", "11:00 AM Team Meeting", "3:30 PM Budget review"] | |
// Do any additional setup after loading the view, typically from a nib. | |
let offset = 20 | |
var counter = 0 | |
for value in events { | |
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 21)) |
func minimumMaximum<T: Comparable>(_ array: [T]) -> (minimum: T, maximum: T)? { | |
var array = array | |
guard !array.isEmpty else { | |
return nil | |
} | |
var minimum = array.first! | |
var maximum = array.first! | |
let hasOddNumberOfItems = array.count % 2 != 0 |
func countOccurrencesOfKey(_ key: Int, inArray a: [Int]) -> Int { | |
func leftBoundary() -> Int { | |
var low = 0 | |
var high = a.count | |
while low < high { | |
let midIndex = low + (high - low)/2 | |
if a[midIndex] < key { | |
low = midIndex + 1 | |
} else { | |
high = midIndex |
func mergeSort(_ array: [Int]) -> [Int] { | |
guard array.count > 1 else { return array } // 1 | |
let middleIndex = array.count / 2 // 2 | |
let leftArray = mergeSort(Array(array[0..<middleIndex])) // 3 | |
let rightArray = mergeSort(Array(array[middleIndex..<array.count])) // 4 | |
return merge(leftPile: leftArray, rightPile: rightArray) // 5 |
public struct Queue<T> { | |
fileprivate var array = [T?]() | |
fileprivate var head = 0 | |
public var isEmpty: Bool { | |
return count == 0 | |
} | |
public var count: Int { | |
return array.count - head |
public struct Stack<T> { | |
fileprivate var array = [T]() | |
public var isEmpty: Bool { | |
return array.isEmpty | |
} | |
public var count: Int { | |
return array.count | |
} |