Commit 3482c976 authored by Carlos Davide's avatar Carlos Davide

day 3

parent fb892ec4
......@@ -5,3 +5,9 @@ Created for "13brane's holidazed cavalcade of code shenanigans: the flavors of F
Relevant rant on 13brane.net:
<https://13brane.net/rants/holidazed-cavalcade-2018-day-0/>
Index:
- **day 1**: The no BS, competent junior dev approach.
- **day 2**: CompSci 101: Structured Programming (Good student version).
- **day 3**: CompSci 101: (Un)Structured Programming (Bad student version).
......@@ -7,7 +7,7 @@ import (
// we'll add the implementations here...
"gitlab.com/carlosdavidepto/cavalcade-2018/day01"
"gitlab.com/carlosdavidepto/cavalcade-2018/day02"
// "gitlab.com/carlosdavidepto/cavalcade-2018/day03"
"gitlab.com/carlosdavidepto/cavalcade-2018/day03"
// "gitlab.com/carlosdavidepto/cavalcade-2018/day04"
// "gitlab.com/carlosdavidepto/cavalcade-2018/day05"
// "gitlab.com/carlosdavidepto/cavalcade-2018/day06"
......@@ -36,7 +36,7 @@ func TestAllImplementations(t *testing.T) {
// ... and here.
day01.FizzBuzz,
day02.FizzBuzz,
// day03.FizzBuzz,
day03.FizzBuzz,
// day04.FizzBuzz,
// day05.FizzBuzz,
// day06.FizzBuzz,
......
package day03
import "fmt"
var divBy3 bool
var by5 bool
var out string
var flag bool
func FizzBuzz(n int) string {
// clean variable
divBy3 = false
by5 = false
out = ""
flag = false
divBy3 = n%3 == 0
by5 = n%5 == 0
if divBy3 {
out = out + "fizz"
flag = true
}
if by5 {
out = out + "buzz"
flag = true
}
if !flag {
out = fmt.Sprint(n)
}
return out
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment