summaryrefslogtreecommitdiff
path: root/p113/p113.go
diff options
context:
space:
mode:
Diffstat (limited to 'p113/p113.go')
-rw-r--r--p113/p113.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/p113/p113.go b/p113/p113.go
new file mode 100644
index 0000000..fc61465
--- /dev/null
+++ b/p113/p113.go
@@ -0,0 +1,75 @@
+package main
+
+import "fmt"
+
+const (
+ LIMITE = 0.99
+)
+
+func isBouncy( a int ) int {
+ if a < 101 {
+ return 0;
+ }
+ c, d := 0, 0
+
+ inc := 0
+
+ for c == d && a != 0 {
+ d = a % 10
+ a /= 10
+ c = a % 10
+ }
+ if c == d {
+ return 2;
+ }
+ if c < d {
+ inc = 1
+ for c <= d && a != 0 {
+ d = a % 10
+ a /= 10
+ c = a % 10
+ }
+ } else {
+ inc = -1
+ for c >= d && a != 0 {
+ d = a % 10
+ a /= 10
+ c = a % 10
+ }
+ }
+ if( a == 0 ) {
+ return inc
+ } else {
+ return 0
+ }
+}
+
+func main() {
+ tot := 0
+ i := 0
+
+ inc := 0
+ dec := 0
+ bon := 0
+
+
+ for i = 0 ; i < 10000 ; i++ {
+ if isBouncy(i) < 0 {
+ dec++
+ } else if isBouncy(i) == 0 {
+ bon++
+ } else if isBouncy(i) == 1 {
+ inc++
+ } else {
+ dec++
+ inc++
+ }
+ tot+=1.
+ }
+
+ fmt.Println(dec);
+ fmt.Println(inc);
+ fmt.Println(bon);
+ fmt.Println(tot-bon);
+ fmt.Println(tot);
+}