Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions zmj/readme.md
Original file line number Diff line number Diff line change
@@ -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`.
3 changes: 3 additions & 0 deletions zmj/roman.fsx
Original file line number Diff line number Diff line change
@@ -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,""))