Skip to content

Instantly share code, notes, and snippets.

@tsraveling
Last active April 24, 2019 19:48
Show Gist options
  • Save tsraveling/708d01902f4e3d20de6ad85f62f2394a to your computer and use it in GitHub Desktop.
Save tsraveling/708d01902f4e3d20de6ad85f62f2394a to your computer and use it in GitHub Desktop.
Codility Playground import
import UIKit
// Put the Codility test question in here
public func solution(_ A : inout [Int]) -> Int {
// write your code in Swift 4.2.1 (Linux)
// Answer return
return 1
}
// Define your test cases and expected answers here
var testCases = [
(list: [5, 4, -3, 4, -3, 5, -3, 5], expected: 4),
(list: [1], expected: 1),
(list: [1, 2, 3], expected: 2)
]
// This part processes your solutions and prints answers to the console
for testCase in testCases {
print("\nTESTING: \(testCase.list)")
var list = testCase.list
let answer = solution(&list)
print("Expected \(testCase.expected), got \(answer)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment