summaryrefslogtreecommitdiff
path: root/p112/p112.go
diff options
context:
space:
mode:
Diffstat (limited to 'p112/p112.go')
-rw-r--r--p112/p112.go52
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);
+}