Skip to content

Instantly share code, notes, and snippets.

@vituscze
Created March 18, 2026 04:54
Show Gist options
  • Select an option

  • Save vituscze/23730a374155b2ceebae94850c19cd44 to your computer and use it in GitHub Desktop.

Select an option

Save vituscze/23730a374155b2ceebae94850c19cd44 to your computer and use it in GitHub Desktop.
cone([o,o,o], 0).
cone(R, 1) :- select(x, R, [o,o]).
cone(R, 2) :- select(o, R, [x,x]).
cone([x,x,x], 3).
match([_,_], []).
match([A,B,C|R], [M|RM]) :- cone([A,B,C],M), match([B,C|R], RM).
mines(Count, Mines) :- same_length(Count, Mines), append([[o],Mines,[o]], M), match(M, Count).
table(T) :- T =
[1 : [i],
4 : [i, v], 5 : [v],
9 : [i, x], 10 : [x],
40 : [x, l], 50 : [l],
90 : [x, c], 100 : [c],
400 : [c, d], 500 : [d],
900 : [c, m], 1000 : [m],
10_000 : [err]].
roman(0, []).
roman(N, L) :- N in 1..3999, table(T),
nextto(V : P, V1 : _, T), V #=< N, N #< V1,
N1 #= N - V, append(P, L1, L), roman(N1, L1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment