Sha256: 75ec5872cc097078ea1d9dfab9d6b84833f559c791c449fb13130889d0d8f819

Contents?: true

Size: 445 Bytes

Versions: 396

Compression:

Stored size: 445 Bytes

Contents

enum Allergen: UInt {
    case eggs = 1
    case peanuts = 2
    case shellfish = 4
    case strawberries = 8
    case tomatoes = 16
    case chocolate = 32
    case pollen = 64
    case cats = 128
}

struct Allergies {

    let score: UInt

    init(_ score: UInt) {
        self.score = UInt(score)
    }

    func hasAllergy(_ allergen: Allergen) -> Bool {
        return allergen.rawValue & score == allergen.rawValue ? true : false
    }
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.179 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.178 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.177 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.176 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.175 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.174 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.173 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.172 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.171 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.170 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.169 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.167 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.166 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.165 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.164 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.163 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.162 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.161 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift
trackler-2.2.1.160 tracks/swift/exercises/allergies/Sources/AllergiesExample.swift