-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain2.go
55 lines (44 loc) · 769 Bytes
/
main2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import "fmt"
func main() {
input := make(chan int, 0)
output := make(chan int, 0)
done1 := make(chan struct{})
go func() {
vm := NewVM(input, output)
vm.Code[0] = 2
vm.Run()
close(output)
done1 <- struct{}{}
}()
done2 := make(chan struct{})
go func() {
defer func() {
done2 <- struct{}{}
}()
for x := range output {
if x > 127 {
fmt.Println(x)
return
}
}
}()
// Send main
send(input, "A,B,A,C,A,A,C,B,C,B")
// Send A
send(input, "L,12,L,8,R,12")
// Send B
send(input, "L,10,L,8,L,12,R,12")
// Send C
send(input, "R,12,L,8,L,10")
// continuous video feed
send(input, "n")
<-done1
<-done2
}
func send(input chan<- int, s string) {
for _, r := range s {
input <- int(r)
}
input <- '\n'
}