0 people like it.

Euler 28

Implementation of Project Euler question 28.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
let Problem28 =
    ([3..+2..1001] |> List.map (fun x -> (x, x*x))
                   |> List.map (fun (n, s) -> let interval = n - 1
                                              let tl = s - interval
                                              let tr = s
                                              let br = s - (interval * 3)
                                              let bl = s - (interval * 2)
                                              (n, s, (tl, tr, br, bl)))
                   |> List.map (fun (_, _, (tl, tr, br, bl)) -> tl + tr + br + bl)
                   |> List.sum) + 1
val Problem28 : int

Full name: Script.Problem28
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val map : mapping:('T -> 'U) -> list:'T list -> 'U list

Full name: Microsoft.FSharp.Collections.List.map
val x : int
val n : int
val s : int
val interval : int
val tl : int
val tr : int
val br : int
val bl : int
val sum : list:'T list -> 'T (requires member ( + ) and member get_Zero)

Full name: Microsoft.FSharp.Collections.List.sum
Raw view Test code New version

More information

Link:http://fssnip.net/de
Posted:12 years ago
Author:Bret Colloff
Tags: euler , 28