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
| extension String { | |
| /// Returns whether the string is a pangram or not | |
| public func isPangram() -> Bool { | |
| if count < 26 { return false } | |
| var alphabetOccurances = Array(repeating: false, count: 26) | |
| var totalCount = 0 | |
| for char in lowercased() { | |
| if let ascii = char.asciiValue { | |
| let index = Int(ascii) - 97 |
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
| import Foundation | |
| extension Array where Element == Int { | |
| /// Returns a decoded version of a delta encoded array | |
| public func deltaDecoded() -> [Element] { | |
| let filteredArray = filterArray(self) | |
| var cummulativeSum = 0 | |
| var decodedValues = [Element]() |
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
| import Foundation | |
| // MARK: - Reverse Array | |
| func reverse<T>(array: [T]) -> [T] { | |
| var reversedArray = array | |
| var index = 0 | |
| while index < array.count { | |
| reversedArray[index] = array[array.count - index - 1] | |
| index += 1 | |
| } |
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
| import UIKit | |
| // MARK: - Node | |
| class Node<T: Equatable> { | |
| var value: T? | |
| var next: Node<T>? | |
| var previous: Node<T>? | |
| init() {} | |
| } |
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
| import Foundation | |
| // MARK: - Interval | |
| struct Interval { | |
| var low: Int | |
| var high: Int | |
| func overlaps(_ otherInterval: Interval) -> Bool { | |
| return contains(otherInterval.low) || contains(otherInterval.high) | |
| } |
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
| import Foundation | |
| let mod = 10000000 // 10e7 | |
| func fastPow(base: Int, power: Int, mod: Int = mod) -> Int { | |
| // Base cases | |
| if base == 0 { | |
| return 0 | |
| } else if power == 0 { | |
| return 1 |
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
| enum Formatters { | |
| static var apiDate: DateFormatter = { | |
| let formatter = DateFormatter() | |
| formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" | |
| return formatter | |
| }() | |
| static var uiDisplay: DateFormatter = { | |
| let formatter = DateFormatter() | |
| formatter.dateStyle = .long |
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
| import UIKit | |
| extension UIColor { | |
| // MARK: - Backgrounds | |
| static var mainBackground = UIColor(named: "mainBackground")! | |
| static var secondaryBackground = UIColor(named: "secondaryBackground")! | |
| static var elevatedBackground = UIColor(named: "elevatedBackground")! | |
| static var separator = UIColor(named: "seperator")! | |
| static var navigationBarTint = UIColor(named: "navigationBarTint")! |
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
| import UIKit | |
| class BaseCollectionViewCell: UICollectionViewCell, Identifiable { | |
| override init(frame: CGRect) { | |
| super.init(frame: .zero) | |
| setupViews() | |
| setupConstraints() | |
| } |