Skip to content

Instantly share code, notes, and snippets.

@watr
Last active September 6, 2018 10:48
Show Gist options
  • Save watr/2629ed09b7fe8d43fbaacc188ff3c492 to your computer and use it in GitHub Desktop.
Save watr/2629ed09b7fe8d43fbaacc188ff3c492 to your computer and use it in GitHub Desktop.
オフラインどう書くの課題を Swift で解くときの雛形
// 横浜へなちょこプログラミング勉強会 | Doorkeeper
// https://yhpg.doorkeeper.jp/
import Foundation
var test_count = 0
var ok_count = 0
var ng_count = 0
func solve(input: String) -> String {
// この関数(solve())の処理書き換えることで問題を解く
return "1,0,0,0,0" //もちろん return する値も書き換えるべし
}
func test(_ input: String, _ expected: String) {
test_count += 1
let answer = solve(input: input)
if answer == expected {
ok_count += 1
}
else {
ng_count += 1
print("test \(test_count - 1) FAILED.")
print(" input: \(input)")
print("expected: \(expected)")
print(" actual: \(answer)")
print()
}
}
//ここにテスト用のコード test(...);...;test(...);をコピー&ペーストする
print("total test count: \(test_count)")
print(" ok count: \(ok_count)")
print(" ng count: \(ng_count)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment