Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

small puzzles
Hello,

I've got two puzzles to solve of which one I managed somehow but the
other I cannot seem to even get started.


Puzzle 1
--------
Given a combination lock with 7 positions (A,B,C,D,E,F,G) of which all
can represent numbers from 1 to 5, we remember following:

C has to be on pos 2.
D has to be on pos 4.
E has to be on pos 3.
G has to be on pos 2.
F is not to be on pos 4.
A is not to be on either pos 1, 2 or 4.
B is not to be on either pos 1, 4 or 5.
If A is on pos 5, F has to be on 1.
If B is on pos 2, D has to be on 1.
If D is on pos 4, A is not to be on pos 3.

My solution to puzzle 1
-----------------------
num(1).
num(2).
num(3).
num(4).
num(5).

combination(A,B,C,D,E,F,G):-
num(A), A \= 1, A \= 2, A \= 4,
num(B), B \= 1, B \= 4, B \= 5,
num(C), C is 2,
num(D), D is 4,
num(E), E is 3,
num(F), F \= 4,
num(G), G is 2,
((A is 5,F is 1);(A \= 5)),
((B is 2,D is 1);(B \= 2)),
((D is 4,A \= 3);(D \= 4)).

I'm sure there is a better one, could anyone maybe point me to it?


Puzzle 2
--------
A family is about to visit their friends. They are a bit complicated as
to who is going. The problematic part of the family consist of Mr.
Funky, Mrs. Funky, the kids Marc and Joseline and grandpa Funky. The
rules are as follows:

If Mrs. Funky goes, his wife goes as well.
At least one of the kids Marc and Joseline will be going.
If Marc goes, grandpa Funky will be going.
If Mrs. Funky goes, grandpa Funky will not be going.
If Joseline goes, Mr. Funky and Marcel will be going.

Who will be visiting their friends?

I'd be happy to get some pointers or even a solution.
eb
--

Report this thread to moderator Post Follow-up to this message
Old Post
el_bandido@nospam.com
12-07-04 09:13 AM


Re: small puzzles
el_bandido@nospam.com wrote:
> Hello,
>
> I've got two puzzles to solve of which one I managed somehow but the
> other I cannot seem to even get started.
>
>
> Puzzle 1
> --------
> Given a combination lock with 7 positions (A,B,C,D,E,F,G) of which all
> can represent numbers from 1 to 5, we remember following:
>
> C has to be on pos 2.
> D has to be on pos 4.
> E has to be on pos 3.
> G has to be on pos 2.
> F is not to be on pos 4.
> A is not to be on either pos 1, 2 or 4.
> B is not to be on either pos 1, 4 or 5.
> If A is on pos 5, F has to be on 1.
> If B is on pos 2, D has to be on 1.
> If D is on pos 4, A is not to be on pos 3.
>
> My solution to puzzle 1
> -----------------------
> num(1).
> num(2).
> num(3).
> num(4).
> num(5).
>
> combination(A,B,C,D,E,F,G):-
>         num(A), A \= 1, A \= 2, A \= 4,
>         num(B), B \= 1, B \= 4, B \= 5,
>         num(C), C is 2,
>         num(D), D is 4,
>         num(E), E is 3,
>         num(F), F \= 4,
>         num(G), G is 2,
>         ((A is 5,F is 1);(A \= 5)),
>         ((B is 2,D is 1);(B \= 2)),
>         ((D is 4,A \= 3);(D \= 4)).
>
> I'm sure there is a better one, could anyone maybe point me to it?
>
>
> Puzzle 2
> --------
> A family is about to visit their friends. They are a bit complicated as
> to who is going. The problematic part of the family consist of Mr.
> Funky, Mrs. Funky, the kids Marc and Joseline and grandpa Funky. The
> rules are as follows:
>
> If Mrs. Funky goes, his wife goes as well.
> At least one of the kids Marc and Joseline will be going.
> If Marc goes, grandpa Funky will be going.
> If Mrs. Funky goes, grandpa Funky will not be going.
> If Joseline goes, Mr. Funky and Marcel will be going.
>
> Who will be visiting their friends?
>
> I'd be happy to get some pointers or even a solution.
> eb

I think a good tip for this problem is:

Advice: Create a variable for each member of the family, which can have
the constant values 'yes' or 'no'.

Report this thread to moderator Post Follow-up to this message
Old Post
KBoy
12-07-04 09:13 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:16 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.