LoginSignup
3
3

More than 5 years have passed since last update.

ズンドコキヨシ with Go

Posted at

元ネタ:https://twitter.com/kumiromilk/status/707437861881180160

Golang初心者が頑張って書いてみたよ!

Go

Sleepを挟んだのはズンドコ感を味わってもらうためです。

package main

import (
  "fmt"
  "math/rand"
  "time"
  "reflect"
  "os"
)

func main() {
  zun := "ズン"
  doko := "ドコ"
  zundoko := []string{zun, doko}
  zzzzdoko := []string{zun, zun, zun, zun, doko}
  lyrics := []string{}

  rand.Seed(time.Now().UnixNano())

  for {
    time.Sleep(1 * time.Second)
    word := zundoko[rand.Intn(2)]
    fmt.Print(word + " ")
    lyrics = append(lyrics, word)
    if len(lyrics) >= 5 {
      length := len(lyrics)
      some_lyrics := lyrics[length-5:]
      if reflect.DeepEqual(some_lyrics, zzzzdoko) {
        fmt.Print("キ・ヨ・シ!")
        os.Exit(0)
      }
    }
  }
}
3
3
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
3
3