This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a scip model for solving the brain teaser found at | |
# https://www.braingle.com/brainteasers/113/change-for-a-dollar.html | |
# To see the answer, run: | |
# echo -e 'read 113.zpl\ncount\nquit' | scip | grep 'Feasible Solutions' | |
param total := 100; # a dollar in cents | |
# how many of each coin will be used? | |
var x01 integer; subto sm01: x01 <= total; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a scip model for solving the brain teaser found at | |
# https://www.braingle.com/brainteasers/21206/pocket-full-of-change.html | |
param total := 10*100; # $10 in cents | |
# how many of each coin will be used? | |
var x01 integer; subto sm01: x01 <= total; | |
var x05 integer; subto sm05: x05 <= total; | |
var x10 integer; subto sm10: x10 <= total; | |
var x25 integer; subto sm25: x25 <= total; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a scip model for solving the brain teaser found at | |
# https://www.braingle.com/brainteasers/5093/common-cents.html | |
param total := 1*100; # $1 in cents | |
set persons := { "E","R","J","M" }; | |
# how many coins does each person have? | |
var x01[persons] integer; subto z01: forall <p> in persons: x01[p]>=0; | |
var x05[persons] integer; subto z05: forall <p> in persons: x05[p]>=0; | |
var x10[persons] integer; subto z10: forall <p> in persons: x10[p]>=0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a scip model for solving the brain teaser found at | |
# https://www.braingle.com/brainteasers/51899/magic-hourglass.html | |
set N := {"A","B","C", | |
"D","E", | |
"F", | |
"G","H", | |
"I","J","K" }; | |
var x[N] integer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A scip model for solving the puzzle at | |
# https://www.puzzleprime.com/brain-teasers/deduction/king-octopus-and-his-servants/ | |
set s1to4 := { 1..4 }; | |
var l[s1to4] integer >=6 <=8 ; # number of legs of each octopus (between 6 and 8) | |
var tl integer >=0 <= 32; # total number of legs | |
subto t0: sum <s> in s1to4: l[s] == tl; | |
var x[s1to4] binary; # is this octopus telling the truth? | |
subto t1:forall <s> in s1to4 do vif l[s]==6 then x[s]==1 end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A scip model for solving the puzzle at | |
# https://www.puzzleprime.com/brain-teasers/deduction/the-ping-pong-puzzle/ | |
set players := { 'A','B','C' }; | |
param NM := 21; # 21 = (10+15+17)/2 number of matches | |
set matches := { 1..NM }; | |
set m3p := matches*players*players*players; | |
set m2p := matches*players*players; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A scip model for solving the puzzle at | |
# https://www.puzzleprime.com/brain-teasers/deduction/broken-clock/ | |
set hours := { 1..12 }; | |
set pieces := { 1..3 }; | |
# definition of next hour (modulo 12) | |
defnumb nexthour(h):= if (h==12) then ( 1) else (h+1) end; | |
# m[h,p]=1 means that the number h belongs to piece p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A scip model for solving the puzzle at | |
# https://www.puzzleprime.com/brain-teasers/deduction/the-dark-bridge/ | |
param ncrossings := 25; | |
set friends := { 1..4 }; | |
set ntimes := { 1,2,7,10 }; # time needed to cross the bridge | |
set xings := { 1..ncrossings }; # bridge crossings | |
var x[xings * friends] binary; # which friends cross the bridge every time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A scip model for solving the puzzle at | |
# https://www.puzzleprime.com/brain-teasers/deduction/missionaries-cannibals/ | |
param ncrossings := 30; | |
set people := { 'M1','M2','M3', 'C1','C2','C3' }; # 3 missionaries/3 cannibals | |
defbool missionary(p):= (p=='M1' or p=='M2' or p=='M3'); | |
defbool cannibal(p) := (not(missionary(p))); | |
set xings := { 1..ncrossings }; # river crossings | |
var x[xings * people] binary; # who cross the river every time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A scip model for solving the puzzle at | |
# https://www.puzzleprime.com/brain-teasers/deduction/send-more-money/ | |
set letters := { 'D', 'E', 'M', 'N', 'O', 'R', 'S', 'Y' }; | |
# what digit does each letter represent? | |
var digits[letters] integer >=0 <=9; | |
# all digits must be different | |
subto d: forall <l1,l2> in letters*letters with l1 > l2 do |
OlderNewer