diff options
author | ache <ache@ache.one> | 2018-09-05 00:56:09 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2018-09-05 00:56:09 +0200 |
commit | 2bae1659ba8eb742f737ccb31d9ad7f25f9599f7 (patch) | |
tree | d8ad2b75cefbcc70f9c31f154682a44299958f67 /p112 |
Init commit
Diffstat (limited to 'p112')
-rw-r--r-- | p112/p112.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/p112/p112.go b/p112/p112.go new file mode 100644 index 0000000..91e5961 --- /dev/null +++ b/p112/p112.go @@ -0,0 +1,52 @@ +package main + +import "fmt" + +const ( + LIMITE = 0.99 +) + +func isBouncy( a int ) bool { + if a < 101 { + return false; + } + c, d := 0, 0 + + for c == d && a != 0 { + d = a % 10 + a /= 10 + c = a % 10 + } + if c == d { + return false; + } + if c < d { + for c <= d && a != 0 { + d = a % 10 + a /= 10 + c = a % 10 + } + } else { + for c >= d && a != 0 { + d = a % 10 + a /= 10 + c = a % 10 + } + } + return a != 0 +} + +func main() { + num := 0. + tot := 10. + i := 0 + + for i = 11 ; num/tot < LIMITE ; i++ { + if isBouncy(i) { + num+=1. + } + tot+=1. + } + + fmt.Println(i-1); +} |