Excellent! Great job!
You deserve more stars for doing it in Ruby,
and it’s quite educational. Thank you!
Actually, I wanted to see how ugly it’d be done
in a “public static void” language.
(IMHO, Java and C++ are on the dark side of CS).
BTW, that answer was provided by the author of the logic
problem on his web site, so you might ask him for a reward.
My Prolog solution provided the same answers,
and therefore, it’s not “wrong.”
It’s a constraint satisfaction problem with very little
logic involved (it’s for humans with no computers). Your conclusion:
“Evidently Prolog isn’t well suited for logic problems” is far from
being evident. Also, you can ask the experts at comp.lang.prolog,
if you “wonder what it is good for.”
Any way, below is a more demanding problem. It’s been used as
an official benchmark in the field. You have an opportunity
to push the recognition of the Ruby language to the top.
(I think the optimal span was proved to be 930 time units –
need to google that).
Best Regards,
Leon
% MT10 Scheduling Problem
% J. F. Muth and G. L. Thompson. Industrial Scheduling.
% Prentice Hall, Englewood Cliffs, NJ, USA, 1963.
%
% MT10 was considered as an especially hard problem for several years.
% It took more than 25 years that the optimality of a found makespan
% was proven.
% J. Carlier and E. Pinson. An algorithm for solving the job-shop
problem.
% Management Science, 35(2):164-176, 1989.
% Ten jobs (a-j), with ten tasks (1-10) each run on ten machines
(m1-m10)
% for N time units after completion of a specified list of tasks.
% E.g., t(b5,69,[b4],m4) – job B task 5 needs 69 time units on machine
% m4 after task b4. Only one task can use a machine…
mt10([
t(a1,29,[],m1), t(a2,78 ,[a1],m2), t(a3, 9,[a2],m3), t(a4,36
,[a3],m4), t(a5,49,[a4],m5), t(a6,11 ,[a5],m6), t(a7,62,[a6],m7),
t(a8,56 ,[a7],m8), t(a9,44,[a8],m9), t(a10,21,[a9],m10),
t(b1,43,[],m1), t(b2,90 ,[b1],m3), t(b3,75,[b2],m5), t(b4,11
,[b3],m10), t(b5,69,[b4],m4), t(b6,28 ,[b5],m2), t(b7,46,[b6],m7),
t(b8,46 ,[b7],m6), t(b9,72,[b8],m8), t(b10,30,[b9],m9),
t(c1,91,[],m2),
t(c2,85 ,[c1],m1), t(c3,39,[c2],m4), t(c4,74 ,[c3],m3),
t(c5,90,[c4],m9), t(c6,10 ,[c5],m6), t(c7,12,[c6],m8), t(c8,89
,[c7],m7), t(c9,45,[c8],m10), t(c10,33,[c9],m5), t(d1,81,[],m2),
t(d2,95
,[d1],m3), t(d3,71,[d2],m1), t(d4,99 ,[d3],m5), t(d5, 9,[d4],m7),
t(d6,52 ,[d5],m9), t(d7,85,[d6],m8), t(d8,98 ,[d7],m4),
t(d9,22,[d8],m10), t(d10,43,[d9],m6), t(e1,14,[],m3), t(e2, 6
,[e1],m1), t(e3,22,[e2],m2), t(e4,61 ,[e3],m6), t(e5,26,[e4],m4),
t(e6,69 ,[e5],m5), t(e7,21,[e6],m9), t(e8,49 ,[e7],m8),
t(e9,72,[e8],m10), t(e10,53,[e9],m7), t(f1,84,[],m3), t(f2, 2
,[f1],m2), t(f3,52,[f2],m6), t(f4,95 ,[f3],m4), t(f5,48,[f4],m9),
t(f6,72 ,[f5],m10), t(f7,47,[f6],m1), t(f8,65 ,[f7],m7), t(f9,
6,[f8],m5), t(f10,25,[f9],m8), t(g1,46,[],m2), t(g2,37 ,[g1],m1),
t(g3,61,[g2],m4), t(g4,13 ,[g3],m3), t(g5,32,[g4],m7), t(g6,21
,[g5],m6), t(g7,32,[g6],m10), t(g8,89 ,[g7],m9), t(g9,30,[g8],m8),
t(g10,55,[g9],m5), t(h1,31,[],m3), t(h2,86 ,[h1],m1),
t(h3,46,[h2],m2), t(h4,74 ,[h3],m6), t(h5,32,[h4],m5), t(h6,88
,[h5],m7), t(h7,19,[h6],m9), t(h8,48 ,[h7],m10), t(h9,36,[h8],m8),
t(h10,79,[h9],m4), t(i1,76,[],m1), t(i2,69 ,[i1],m2),
t(i3,76,[i2],m4), t(i4,51 ,[i3],m6), t(i5,85,[i4],m3), t(i6,11
,[i5],m10), t(i7,40,[i6],m7), t(i8,89 ,[i7],m8), t(i9,26,[i8],m5),
t(i10,74,[i9],m9), t(j1,85,[],m2), t(j2,13 ,[j1],m1),
t(j3,61,[j2],m3), t(j4, 7 ,[j3],m7), t(j5,64,[j4],m9), t(j6,76
,[j5],m10), t(j7,47,[j6],m6), t(j8,52 ,[j7],m4), t(j9,90,[j8],m5),
t(j10,45,[j9],m8)
]).