Skip to content

Instantly share code, notes, and snippets.

View cbilson's full-sized avatar

Chris Bilson cbilson

View GitHub Profile
#light
(*
Project Euler Problem 6
*)
let sumOfSquares n =
seq { 1 .. n } |> Seq.fold (fun a x -> a + float(x) * float(x)) 0.0
let squareOfSums n =
let sum = seq { 1 .. n } |> Seq.sum
#light
open System
(*
My solution to project euler problem #7
*)
let isPrime x =
{2 .. int(System.Math.Sqrt(float(x)))}
#light
open System
let groups xs l =
seq { for i = 0 to (List.length xs) - l do
yield Seq.skip i xs |> Seq.take l }
let digitSequence = List.of_array ("731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749303589072962904915604407723907138105158593079608667017242712188399879790879227492190169972088809377665727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474821663704844031998900088952434506585412275886668811642717147992444292823086346567481391912316282458617866458359124566529476545682848912883142607690042242190226710556263211111093705442175069416589604080719840385096245544
#light
open System
open System.Collections.Generic
open Microsoft.FSharp.Math
let memoize (f:'a -> 'b) =
let t = new Dictionary<'a, 'b>()
fun n -> if t.ContainsKey(n) then t.[n]
else let res = f n
#light
open System
let text = @"
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
#light
open System
let text = @"
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
#light
(*
Problem 12: Deep Thought Edition
*)
open System
open System.Collections.Generic
open Microsoft.FSharp.Math
let N =
#light
open System
open System.Collections.Generic
open Microsoft.FSharp.Math
let N =
Seq.unfold (fun x -> Some(x, x + 1I)) 1I
let isEven = function
169569432 2008-12-23 00:00:00.000 5095 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2008-12-23 16:48:52.497 PROD\Frs1Apps 2008-12-23 08:47:56.763 PROD\Frs1Apps 2008-12-23 08:48:52.513
169569433 2008-12-23 00:00:00.000 8174 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2008-12-23 16:48:52.497 PROD\Frs1Apps 2008-12-23 08:47:56.763 PROD\Frs1Apps 2008-12-23 08:48:52.513
169569434 2008-12-23 00:00:00.000 10899 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2008-12-23 16:48:52.497 PROD\Frs1Apps 2008-12-23 08:47:56.763 PROD\Frs1Apps 2008-12-23 08:48:52.513
5095 Aluminium of Greece S.A.I.C. alek NULL B11XPS7 GRS081103004 cseu cs EUR GR GR GA NULL NULL NULL 2008-06-17 02:33:00 NULL BBPerSec EQ0011721100001000 0 2008-12-14 03:22:00 15 15104010 0 PROD\Jottinge 2004-01-30 19:46:46.110 PROD\Frs1Apps 2008-12-14 03:21:41.043
8174 Actelion Ltd atln NULL B1YD5Q2 CH0010532478 csch cs CHF CH CH SE NULL NULL NULL 2007-09-24 02:10:00 NULL BBPerSec EQ011
;;
;; Use Consolas as my default font
;;
(set-default-font "-*-Consolas-normal-r-*-*-14-97-*-*-c-*-iso8859-1")
(setq transient-mark-mode t)
(load "C:/Tools/emacs/site-lisp/color-theme.el")
(load "C:/Tools/emacs/site-lisp/color-theme-twilight.el")
(load "C:/Tools/emacs/site-lisp/color-theme-inkpot.el")