Created
September 14, 2018 02:10
-
-
Save jonbodner/20d3f1fcf6f30b60ab0d8f9f2bad7b49 to your computer and use it in GitHub Desktop.
FizzBuzz without if statements
This file contains hidden or 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" | |
"strconv" | |
) | |
func main() { | |
vals := [][]string{{"FizzBuzz", "Fizz"}, {"Buzz", ""}} | |
for i := 1; i <= 100; i++ { | |
vals[1][1] = strconv.Itoa(i) | |
x := ((i % 3) + 2) / 3 | |
y := ((i % 5) + 4) / 5 | |
fmt.Println(vals[x][y]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment