Skip to content

Instantly share code, notes, and snippets.

@el-hoshino
Forked from takasek/CodePiece.swift
Created March 27, 2018 09:08
Show Gist options
  • Save el-hoshino/6cbc640c20c6645ade13b4918a298d58 to your computer and use it in GitHub Desktop.
Save el-hoshino/6cbc640c20c6645ade13b4918a298d58 to your computer and use it in GitHub Desktop.
ポプテピピックが完成したら竹書房を破壊するSwiftコード #CodePiece
enum PopTeamEpic: String {
case po = "ポ"
case p = "プ"
case teame = "テピ"
case pic = "ピック"
}
struct 蒼井翔太: Sequence, IteratorProtocol {
mutating func next() -> PopTeamEpic? {
switch arc4random_uniform(4) {
case 0: return .po
case 1: return .p
case 2: return .teame
case 3: return .pic
case _: fatalError()
}
}
}
class 竹書房 {
private var 並行励起: [PopTeamEpic] = []
struct 破壊: Error {
let 断末魔: String
var localizedDescription: String { return 断末魔 }
}
func receive(_ 🖕: PopTeamEpic) throws {
並行励起.append(🖕)
if 並行励起.suffix(4) == [.po, .p, .teame, .pic] {
throw 破壊(断末魔: 並行励起.map { $0.rawValue }.reduce("", +))
}
}
}
var 🕺 = 蒼井翔太()
let 🏢 = 竹書房()
for 🖕 in 🕺 {
try! 🏢.receive(🖕)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment