Files
2025-08-03 20:16:55 -07:00

18 lines
518 B
FSharp

module _112
let bouncy90 =
let bouncy n =
common.numDigits n
|> Seq.pairwise
|> Seq.filter (fun (i,j) -> i <> j)
|> Seq.map (fun (i,j) -> i > j)
|> Seq.distinct
|> Seq.length > 1
common.allIntegers
|> Seq.skip 1
|> Seq.map (fun i -> (i,bouncy i))
|> Seq.scan (fun (t,f) (i,b) ->
if b then (t+1,f) else (t,f+1)) (0,0)
|> Seq.map (fun (t,f) -> if t = 0 then 0.0 else ((float t)/((float t)+(float f))))
|> Seq.findIndex ((<=) 0.99)