Skip to content

Instantly share code, notes, and snippets.

View JaDenis's full-sized avatar

Denis Zhabbarov JaDenis

View GitHub Profile
@JaDenis
JaDenis / Luhn.swift
Created September 1, 2016 14:55 — forked from cwagdev/Luhn.swift
Luhn Algorithm in Swift
func luhnCheck(number: String) -> Bool {
var sum = 0
let digitStrings = reverse(number).map { String($0) }
for tuple in enumerate(digitStrings) {
if let digit = tuple.element.toInt() {
let odd = tuple.index % 2 == 1
switch (odd, digit) {
case (true, 9):