aboutsummaryrefslogtreecommitdiff
path: root/box.mzn
blob: 0fd6f44c71a737075870065da042bf30b703a09e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
include "globals.mzn";

% Given an integer n and a real e
par int:   n = 566*708;
par float: e = 16/9;

% Find two integers r <= c
var int: r; var int: c;
constraint c >= r;
output [
  "Rows: ",    show(r), "\n",
  "Columns: ", show(c), "\n"
];

% Such that (r-1)c < n <= rc
constraint
  ((r-1)*c) < n
  /\
  n <= (r*c);

% And the ratio c/r is as close to e as possible.
solve minimize abs(c/r - e);