Goofing around with some teensy FizzBuzz
This commit is contained in:
parent
0b171d63b5
commit
5077e5302e
4
zzz/.gitignore
vendored
Normal file
4
zzz/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/fizzbuzz.txt
|
||||
/fizzbuzz/fizzbuzz
|
||||
/best
|
||||
/fizzbuzz.txt.real
|
24
zzz/Makefile
Normal file
24
zzz/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
all: build golden
|
||||
|
||||
build:
|
||||
@cd fizzbuzz && go build
|
||||
|
||||
golden: build best fizzbuzz.txt fizzbuzz.txt.real
|
||||
@diff -u fizzbuzz.txt fizzbuzz.txt.real
|
||||
@export CUR=$$(echo "$$(wc -c fizzbuzz/main.go | awk '{ print $$1 }') - 43" | bc) ; \
|
||||
export BEST=$$(cat best) ; \
|
||||
echo $$CUR > best ; \
|
||||
echo $$CUR '<=' $$BEST ; \
|
||||
test $$CUR -le $$BEST ; \
|
||||
echo "scale=2; (200.0 - $$CUR) / 10.0" | bc
|
||||
|
||||
fizzbuzz.txt.real:
|
||||
./fizzbuzz/fizzbuzz > $@
|
||||
|
||||
best:
|
||||
echo 400 > $@
|
||||
|
||||
fizzbuzz.txt:
|
||||
curl -O http://cdn.hackerrank.com/fizzbuzz.txt
|
||||
|
||||
.PHONY: all build golden
|
5
zzz/baseline.go
Normal file
5
zzz/baseline.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
}
|
15
zzz/fizzbuzz/main.go
Normal file
15
zzz/fizzbuzz/main.go
Normal file
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
for i, s := 1, ""; i < 101; i++ {
|
||||
if i%3 == 0 {
|
||||
s = "Fizz"
|
||||
if i%5 == 0 {
|
||||
s += "Buzz"
|
||||
}
|
||||
} else if i%5 == 0 {
|
||||
s = "Buzz"
|
||||
}
|
||||
print(s)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user