Skip to content

Instantly share code, notes, and snippets.

@owulveryck
Created February 1, 2023 15:12
Show Gist options
  • Save owulveryck/cd49dc82ae8b3bbfaf510821c489fbbf to your computer and use it in GitHub Desktop.
Save owulveryck/cd49dc82ae8b3bbfaf510821c489fbbf to your computer and use it in GitHub Desktop.
Random Coffee

cat data | go run main.go

person1
person2
person3
person4
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
s := bufio.NewScanner(os.Stdin)
s.Split(bufio.ScanLines)
entries := make(map[string]struct{})
for s.Scan() {
entries[s.Text()] = struct{}{}
}
separator := [2]string{" \u2615 ", "\n"}
i := 0
for k := range entries {
fmt.Printf("@%v%v", k, separator[i%len(separator)])
i++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment