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
func isValidCreditCardNumber(number: String) -> Bool { | |
guard !number.isEmpty else { return false } | |
let revesedString = String(number.characters.reverse()) | |
var oddNumberSum = 0 | |
var evenNumberSum = 0 | |
for index in 0..<revesedString.characters.count { | |
let digit = Int(String(revesedString[revesedString.startIndex.advancedBy(index)]))! | |
let pos = index + 1 | |
if pos % 2 == 0 { |
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
class MyHashMap<T,K>() { | |
var array: ArrayList<Item<T,K>> = ArrayList() | |
fun addItem(item: Item<T,K>) { | |
array.add(item) | |
} | |
fun addItem(key: T, value: K) { | |
array.add(Item<T,K>(key, value)) | |
} |
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 | |
class Bindable<Value> : NSObject { | |
private var observations = [(Value) -> Bool]() | |
private var lastValue: Value? | |
init(_ value: Value? = nil) { | |
lastValue = value | |
} | |
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 class EBLE { | |
EBLE_ZERO, // Zero element | |
EBLE_FLAGS, //«Flags» Bluetooth Core Specification: | |
EBLE_16BitUUIDInc, //«Incomplete List of 16-bit Service Class UUIDs» Bluetooth Core Specification: | |
EBLE_16BitUUIDCom, //«Complete List of 16-bit Service Class UUIDs» Bluetooth Core Specification: | |
EBLE_32BitUUIDInc,//«Incomplete List of 32-bit Service Class UUIDs» Bluetooth Core Specification: | |
EBLE_32BitUUIDCom,//«Complete List of 32-bit Service Class UUIDs» Bluetooth Core Specification: | |
EBLE_128BitUUIDInc,//«Incomplete List of 128-bit Service Class UUIDs» Bluetooth Core Specification: | |
EBLE_128BitUUIDCom,//«Complete List of 128-bit Service Class UUIDs» Bluetooth Core Specification: |