diff --git a/fizzbuzz-threads/go.mod b/fizzbuzz-threads/go.mod new file mode 100644 index 0000000..29cd418 --- /dev/null +++ b/fizzbuzz-threads/go.mod @@ -0,0 +1,3 @@ +module fizzbuzz-threads + +go 1.22.1 diff --git a/fizzbuzz-threads/main.go b/fizzbuzz-threads/main.go new file mode 100644 index 0000000..10aed3b --- /dev/null +++ b/fizzbuzz-threads/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" +) + +func fizz(c chan int) { + num := <-c + if num%3 == 0 { + //str := "FIZZ" + c <- 1000 + } + + c <- 0 +} + +func buzz(c chan int) { + +} + +func fizzbuzz(c chan int) { + +} + +func main() { + fiz := make(chan int) + buz := make(chan int) + fizbuz := make(chan int) + + go fizz(fiz) + go buzz(buz) + go fizzbuzz(fizbuz) + + for i := 0; i < 100; i++ { + fiz <- i + fizzed := <-fiz + println(fizzed) + } +}