/* 100 students problem in Picat. From https://twitter.com/mathisstillfun/status/1588002151804157952 """ 100 students take an exam with 4 questions. 90 solve the first question, 85 the second, 80 the third, and 70 the fourth. Determine the smallest possible number of students that have solved all four questions """ Solution: 25 students MIP: cbc: 0.152s glpk: 0.118s All the other solvers are way too slow on this. This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import mip. % import smt. % import sat. % import cp. main => go. go => N = 100, M = 4, X = new_array(M,N), X :: 0..1, sum(X[1]) #= 90, sum(X[2]) #= 85, sum(X[3]) #= 80, sum(X[4]) #= 70, Z #= sum([ sum([X[I,J] : I in 1..M]) #= M : J in 1..N ]), solve($[min(Z),inout,updown,report(printf("z:%d\n",Z))],X.vars), println(z=Z), flush(stdout), fail, nl.