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
type mods struct{ mod3, mod5 bool } | |
var m = map[mods]string{ | |
{false, false}: "", | |
{true, false}: "Fizz", | |
{false, true}: "Buzz", | |
{true, true}: "FizzBuzz", | |
} | |
func fizzbuzz(n int) string { | |
return m[mods{n%3 == 0, n%5 == 0}] |
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" | |
type mods struct{ mod3, mod5 bool } | |
var m = map[mods]string{ | |
{false, false}: "", | |
{true, false}: "Fizz", | |
{false, true}: "Buzz", | |
{true, true}: "FizzBuzz", |