Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 2, 2020 07:40

Revisions

  1. wizard1066 created this gist Apr 2, 2020.
    35 changes: 35 additions & 0 deletions .swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    func confirmColours(textColors:[Color],figures:Int) -> Bool? {
    for loop in 0 ..< figures {
    if textColors[loop] == Color.clear {
    return false
    }
    }
    var tfigures = figures - 1
    let rfigure = Int(Double(figures).squareRoot())
    for _ in 0..<rfigure {
    var superSet = Set<String>()
    for loop in stride(from: tfigures, to: tfigures - rfigure, by: -1) {
    superSet.insert(textColors[loop].description)
    print("loop ",loop)
    }
    tfigures = tfigures - rfigure
    print("superSet ",superSet,superSet.count)
    if superSet.count != rfigure {
    alertPublisher.send()
    }
    }
    tfigures = figures - 1
    for _ in 0..<rfigure {
    var superSet = Set<String>()
    for loop in stride(from: tfigures, to: -1, by: -rfigure) {
    superSet.insert(textColors[loop].description)
    print("loop2 ",loop)
    }
    tfigures = tfigures - 1
    print("superSet ",superSet,superSet.count)
    if superSet.count != rfigure {
    alertPublisher.send()
    }
    }
    return true
    }