Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created March 30, 2011 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AlexCuse/894707 to your computer and use it in GitHub Desktop.
Save AlexCuse/894707 to your computer and use it in GitHub Desktop.
euler repl
#light
module ProjectEuler.Program
open System;
open System.Diagnostics;
open System.Reflection;
let dynamicExecute prob =
let probNum = prob.ToString()
let ass = Assembly.GetExecutingAssembly()
let modul = ass.GetType("ProjectEuler.Problem" + probNum)
let funcs = modul.GetMember("solve")
let func = funcs.[0] :?> PropertyInfo
func.GetValue(modul, null)
let getProblemNumber() =
printf "%s" "Enter problem #: "
let str = Console.ReadLine()
match Int32.TryParse(str) with
| true, parsed -> Some parsed
| _ -> None
let rec eulerRepl() =
let q = getProblemNumber()
if q.IsNone then ()
else
let tmr = Stopwatch.StartNew()
let answer = dynamicExecute q.Value
printfn "Problem %d answer is %A\nSolved In: %A\n\n" q.Value answer tmr.Elapsed
eulerRepl()
eulerRepl()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment