LoginSignup
1
1

More than 5 years have passed since last update.

ズンドコキヨシ with Swift

Posted at

元ネタ

様々なズンドコキヨシ

作ってみる

まあそのままズンドコやっても面白くないから最近お流行りの「ガルパンはいいぞ!」で作ってみたいと思います

import Foundation

let candidates = ["ガルパン", "は", "いい", "ぞ"]
var createdPhrase = [String](count: candidates.count, repeatedValue: "")

for i in 0 ..< Int.max {
    if createdPhrase != candidates {
        let randomNumber = Int(arc4random_uniform(UInt32(candidates.count)))
        let nextWord = candidates[randomNumber]
        print(nextWord)
        createdPhrase.removeFirst()
        createdPhrase.append(nextWord)

    } else {
        print("\(i) times")
        break
    }
}

print(createdPhrase.reduce("", combine: {$0 + $1}) + "!")

出力例

//前略
ガルパン
ぞ
ガルパン
ぞ
ぞ
いい
いい
ガルパン
ガルパン
ガルパン
ぞ
は
いい
ガルパン
は
いい
ぞ
462 times
ガルパンはいいぞ!

ガルパンはいいぞ₍₍ (ง╹◡╹)ว ⁾⁾

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1