Nicholas Maccharoli
github.com/nirma
@din0sr
public enum Prefecture: Int { | |
case Hokkaido = 1, Aomori = 2, Iwate = 3, Miyagi = 4, Akita = 5, | |
Yamagata = 6, Fukushima = 7, Ibaraki = 8, Tochigi = 9, Gunma = 10, | |
Saitama = 11, Chiba = 12, Tokyo = 13, Kanagawa = 14, Niigata = 15, | |
Toyama = 16, Ishikawa = 17, Fukui = 18, Yamanashi = 19, Nagano = 20, | |
Gifu = 21, Shizuoka = 22, Aichi = 23, Mie = 24, Shiga = 25, Kyoto = 26, | |
Osaka = 27, Hyogo = 28, Nara = 29, Wakayama = 30, Tottori = 31, | |
Shimane = 32, Okayama = 33, Hiroshima = 34, Yamaguchi = 35, Tokushima = 36, | |
Kagawa = 37, Ehime = 38, Kochi = 39, Fukuoka = 40, Saga = 41, Nagasaki = 42, | |
Kumamoto = 43, Oita = 44, Miyazaki = 45, Kagoshima = 46, Okinawa = 47 |
extension Array { | |
private func reorderAndNormalized(swapElement indexA: Int, withElement indexB: Int, normalizeBlock: ((Int, Element) -> Element)) -> [Element]? { | |
guard indexA >= 0 && indexA < count else { return nil } | |
guard indexB >= 0 && indexB < count else { return nil } | |
var newItems = self | |
(newItems[indexA], newItems[indexB]) = (newItems[indexB], newItems[indexA]) | |
return newItems.enumerate().map { index, item in |
class Heap { | |
fileprivate var backingStore: [Int] = [Int]() | |
public var count: Int { | |
return backingStore.count | |
} | |
} | |
// MARK: - Indexing |
public enum Prefecture: Int { | |
case hokkaido = 1, aomori = 2, iwate = 3, miyagi = 4, akita = 5, | |
yamagata = 6, fukushima = 7, ibaraki = 8, tochigi = 9, gunma = 10, | |
saitama = 11, chiba = 12, tokyo = 13, kanagawa = 14, niigata = 15, | |
toyama = 16, ishikawa = 17, fukui = 18, yamanashi = 19, nagano = 20, | |
gifu = 21, shizuoka = 22, aichi = 23, mie = 24, shiga = 25, kyoto = 26, | |
osaka = 27, hyogo = 28, nara = 29, wakayama = 30, tottori = 31, | |
shimane = 32, okayama = 33, hiroshima = 34, yamaguchi = 35, tokushima = 36, | |
kagawa = 37, ehime = 38, kochi = 39, fukuoka = 40, saga = 41, nagasaki = 42, | |
kumamoto = 43, oita = 44, miyazaki = 45, kagoshima = 46, okinawa = 47 |
import UIKit | |
@IBDesignable final class ProgressBarView: UIView { | |
@IBInspectable var barColor: UIColor = UIColor.ex.red | |
@IBInspectable var trackColor: UIColor = UIColor.ex.gray | |
@IBInspectable var barThickness: CGFloat = 8.0 | |
@IBInspectable var barPadding: CGFloat = 0.0 | |
@IBInspectable var trackPadding: CGFloat = 0.0 | |
@IBInspectable var progressValue: Int = 0 { |
{- My personal solutions for problems 1 through 10 of | |
- https://wiki.haskell.org/99_questions/1_to_10-} | |
-- Problem 1: Find the last element of a list | |
problemOne :: [a] -> a | |
problemOne x = last x | |
-- Problem 2: Find the second to last element |
func recursiveFib(position: Int) -> Int { | |
if position == 0 || position == 1 { | |
return position | |
} | |
return recursiveFib(position: position - 1) + recursiveFib(position: position - 2) | |
} | |
func dynamicFib(position: Int) -> Int { | |
// Insertion Sort | |
func insertionSort(_ elements: [Int]) -> [Int] { | |
guard elements.count >= 2, let last = elements.last else { return elements } | |
var copy = elements | |
var pivot = last | |
var idx: Int | |
for index in 0..<(elements.count - 1) { | |
idx = index |
git clone --depth 1 https://github.com/apple/swift.git # a shallow clone will do | |
mkdir -p ~/.vim # make a vim folder if its not available already | |
cp -a ./swift/utils/vim/ ~/.vim # just copy over the contents of utils/vim as they are | |
rm -rf # this is just for cleanup |