Skip to content
Snippets Groups Projects
Commit 84c3de9e authored by Philippe Suter's avatar Philippe Suter
Browse files

changse

parent 085927b2
No related branches found
No related tags found
No related merge requests found
...@@ -82,32 +82,33 @@ object PaperExamples extends App { ...@@ -82,32 +82,33 @@ object PaperExamples extends App {
assuming(m(l) >= 0 && m(l) <= 9) { assuming(m(l) >= 0 && m(l) <= 9) {
println("OK for " + l) println("OK for " + l)
} }
// we need this too because S and M occur as most significant digits
if (l == S() || l == M())
assuming(m(l) >= 1) {
println(l + " greater than 0 OK")
}
assuming(
1000 * m(S()) + 100 * m(E()) + 10 * m(N()) + m(D()) +
1000 * m(M()) + 100 * m(O()) + 10 * m(R()) + m(E()) ==
10000 * m(M()) + 1000 * m(O()) + 100 * m(N()) + 10 * m(E()) + m(Y())) {
println("OK for sum")
}
assuming(distinct(m(S()), m(E()), m(N()), m(D()), m(M()), m(O()), m(R()), m(Y()))) { // we need this too because S and M occur as most significant digits
println("OK for distinct") if (l == S() || l == M()) assuming(m(l) >= 1) {
println(l + " greater than 0 OK")
} }
}
assuming(
1000 * m(S()) + 100 * m(E()) + 10 * m(N()) + m(D()) +
1000 * m(M()) + 100 * m(O()) + 10 * m(R()) + m(E()) ==
10000 * m(M()) + 1000 * m(O()) + 100 * m(N()) + 10 * m(E()) + m(Y())) {
println("OK for sum")
} }
assuming(distinct(m(S()), m(E()), m(N()), m(D()), m(M()), m(O()), m(R()), m(Y()))) {
println("OK for distinct")
}
println("A solution : " + m.value) println("A solution : " + m.value)
// functional-style, crashed because of if // functional-style, crashed because of if
val c : Constraint1[Map[Letter,Int]] = ((m: Map[Letter,Int]) => // val c : Constraint1[Map[Letter,Int]] = ((m: Map[Letter,Int]) =>
1000 * m(S()) + 100 * m(E()) + 10 * m(N()) + m(D()) + // 1000 * m(S()) + 100 * m(E()) + 10 * m(N()) + m(D()) +
1000 * m(M()) + 100 * m(O()) + 10 * m(R()) + m(E()) == // 1000 * m(M()) + 100 * m(O()) + 10 * m(R()) + m(E()) ==
10000 * m(M()) + 1000 * m(O()) + 100 * m(N()) + 10 * m(E()) + m(Y())) // 10000 * m(M()) + 1000 * m(O()) + 100 * m(N()) + 10 * m(E()) + m(Y()))
// this works too but I guess we should avoid enumerating maps // this works too but I guess we should avoid enumerating maps
// for(m <- c.lazyFindAll if( // for(m <- c.lazyFindAll if(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment