Last active
March 12, 2016 09:45
-
-
Save hkdnet/2b1a1bae09c4bee046c9 to your computer and use it in GitHub Desktop.
zndk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class Hello{ | |
public static void Main(){ | |
var rnd = new Random(); | |
var zn = "ズン"; | |
var dk = "ドコ"; | |
var expected = "ズンズンズンズンドコ"; | |
var list = new List<string>(); | |
while(true) { | |
var tmp = rnd.Next(2) == 0 ? zn : dk; | |
list.Add(tmp); | |
Console.Write(tmp); | |
var got = string.Join("", list.Skip(list.Count - 5)); | |
if (got == expected) | |
break; | |
} | |
Console.WriteLine("キ・ヨ・シ!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"strings" | |
) | |
func main(){ | |
ch := make(chan string) | |
zns := []string{ "", "", "", ""} | |
go zndk(ch); | |
for { | |
tmp := <- ch | |
fmt.Print(tmp) | |
zns = append(zns, tmp) | |
idx := len(zns) - 5 | |
got := strings.Join(zns[idx:], "") | |
if (got == "ズンズンズンズンドコ") { | |
fmt.Println("キ・ヨ・シ!") | |
break; | |
} | |
} | |
close(ch) | |
} | |
func zndk(ch chan(string)) { | |
for { | |
if rand.Int31n(2) == 0 { | |
ch <-"ズン" | |
} else { | |
ch <- "ドコ" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
出力例