Article View: comp.lang.prolog
Article #4101A Challenge
From: Pat Chkoreff
Date: Sun, 10 Dec 1989 06:53
Date: Sun, 10 Dec 1989 06:53
40 lines
1518 bytes
1518 bytes
Here's a challenge for you. It's a stripped-down version of a problem I've
been working on, and I haven't solved it yet.
Write a predicate good/1 which succeeds if and only if its argument is a
list of lists, where all of the lists have the same length.
All of these queries should work:
?- good([]).
Yes
?- good([[a,b],[c,d]]).
Yes
?- good([[a],[b,c]]).
No
?- good([_,_,_,[a],_,_,_,[b,c],_,_,_|_]). % this one's tough.
No
The predicate should be written using pure Horn clauses -- no calls to !/0
or var/1.
'Same length' is defined by:
same_length([], []).
same_length([_|Xs], [_|Ys]) :-
same_length(Xs, Ys).
Maybe I have no business even trying to solve this problem, but it bothers
me that I can't do it.
Please e-mail candidate solutions (or proofs of intractability) to me: I'll
post the winner. Thanks.
Patrick Chkoreff 719-590-5983
{hpfcla,hplabs}!hpldola!patch
P.S. I'm not really at "Hunga Dunga U.", I'm really at Hewlett-Packard,
Electronic Design Division.
Technical Details
Message-ID:
<11500022@hpldoda.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!brutus.cs.uiuc.edu!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hpfcso!hpldola!hpldoda!patchShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!brutus.cs.uiuc.edu!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hpfcso!hpldola!hpldoda!patch From: patch@hpldoda.UUCP (Pat Chkoreff) Newsgroups: comp.lang.prolog Subject: A Challenge Message-ID: <11500022@hpldoda.UUCP> Date: 10 Dec 89 06:53:58 GMT Organization: Hunga Dunga U. Lines: 40