Skip to content

Instantly share code, notes, and snippets.

@saska-gist
saska-gist / 52558.zpl
Created January 31, 2021 01:29
a scip model for solving the brainteaser at https://www.braingle.com/brainteasers/teaser.php?id=52558
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52558
var xL real; # train length
var xR real; # train speed / human speed
subto r1: xL>=0;
subto r2: xR>=0;
@saska-gist
saska-gist / 52499.zpl
Created January 31, 2021 01:25
a scip model for solving the brainteaser at https://www.braingle.com/brainteasers/teaser.php?id=52499
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52499
set name := {"Sara", "Ophelia", "Nora", "Dawn"};
set month := {"September", "October", "November", "December"};
var x[name * month] binary;
# each girl is born in a different month
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=48171
set persons:= { "Steve", "Reggie", "Gordon", "Frank" };
set floors := { 1, 2, 3, 4 };
set times := {"3:00", "3:30", "4:15", "5:00"};
var person_floor[persons * floors] binary;
var person_time[persons * times ] binary;
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52375
set families:= { "Meyer", "Selman", "Vitti" };
set episodes := {
"The Way We Weren't",
"Simple Simpson",
"Fraudcast News",
"I, D'oh-bot",
"The President Wore Pearls"
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52376
set girls := { "Wanda", "Xenia", "Yolanda", "Zoe" };
param last := card(girls);
set positions := { 1 .. last };
var xbaseball[girls] binary;
var xsoccer[girls] binary;
var xbasketball[girls] binary;
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52386
set statements := { 0 .. 5 };
var x[statements] binary;
subto r0: vif (x[0]==1)
then sum <s> in statements: x[s] >= 4
else sum <s> in statements: x[s] <= 3 end;
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52373
set persons := { "Allie", "Kaleb", "Leah" };
set roles := { "scientist", "psychologist", "lapidary" };
var x[persons*roles] binary;
subto x1: forall <p> in persons do sum <r> in roles : x[p,r] == 1;
subto x2: forall <r> in roles do sum <p> in persons : x[p,r] == 1;
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52285
set persons := {"Quinn", "Ralph", "Steve"};
var Turner[persons] binary;
var Lerner[persons] binary;
subto LorT: forall <p> in persons: Lerner[p] == 1 - Turner[p];
subto Q_t:
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52271
set players := {"Ace", "Callie", "Draco", "Emma", "Eric",
"Holly", "Leah", "Misty", "Quinn", "Xander"};
set teams := { "red", "green", "blue", "black", "white"};
set places := { 1 .. card(teams) };
var x[players * teams] binary;
# a scip model for solving the brainteaser at
# https://www.braingle.com/brainteasers/teaser.php?id=52323
param A:=1; param B:=2; param C:=3; param D:=4;
param E:=5; param F:=6; param G:=7;
set women := { A, B, C, D };
set men := { E, F, G };
set people := women + men;