-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler112.scala
More file actions
35 lines (30 loc) · 802 Bytes
/
euler112.scala
File metadata and controls
35 lines (30 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
object euler112 {
def bouncy(n:Long):Boolean = {
var oldc=' '
var increasing=false
var decreasing=false
for(c <- n.toString){
if(oldc!=' '){
if(! decreasing)decreasing=(c<oldc)
if(! increasing)increasing=(c>oldc)
if(increasing && decreasing)
return true
oldc=c
}else{
oldc=c
}
}
//return increasing && decreasing
return false
}
def main(args: Array[String]) {
var i:Long=0
var nbBouncy:Double=0
var n:Long=99
while(nbBouncy/n.toDouble < 99.0/100.0){
n+=1
if(bouncy(n))nbBouncy+=1
}
println(n)
}
}