diff --git a/zmj/readme.md b/zmj/readme.md new file mode 100644 index 0000000..b81822a --- /dev/null +++ b/zmj/readme.md @@ -0,0 +1,5 @@ +# How do I run this? + +It's a script. `./roman.fsx ../input.txt` should work with the .NET SDK installed. Make sure the file is executable: `chmod +x roman.fsx`. + +If that's not working, invoke the F# REPL directly: `dotnet fsi roman.fsx ../input.txt`. \ No newline at end of file diff --git a/zmj/roman.fsx b/zmj/roman.fsx new file mode 100755 index 0000000..7b4ca8f --- /dev/null +++ b/zmj/roman.fsx @@ -0,0 +1,3 @@ +#!/usr/bin/env -S dotnet fsi +let rec c(n,s)=if n=0 then s else s+c(List.pick(fun(v,d)->if n-v>=0 then Some(n-v,d) else None)(List.zip [1000;900;500;400;100;90;50;40;10;9;5;4;1] ["M";"CM";"D";"CD";"C";"XC";"L";"XL";"X";"IX";"V";"IV";"I"])) +for l in System.IO.File.ReadLines fsi.CommandLineArgs[1] do printfn"%s"(c(int l,""))