Home
Locate
CS 101
CS 496
Login
Tutors
Marks
About
Send
Close
Add comments:
(status displays here)
Got it!
This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.
nbsp; Note: This appears on each machine/browser from which this site is accessed.
Permute DSL for nontrivial puzzle
by RS
admin@ycp.powersoftwo.org
c
go
java
js
lua
py
vbs
rkt
scm
pro
1. Permute DSL for nontrivial puzzle
2. Permute DSL
Here is one way to get started with the nontrivial puzzle using the permute DSL. a
Here is the DSL code.
dsl permute for "pro" domain breed values "cocker spaniel" "Dalmation" "German sheperd" "golden retriever" "Greyhound" names B1 B2 B3 B4 B5 domain first values "Alice" "Carol" "Heidi" "Kay" "Michelle" names F1 F2 F3 F4 F5 domain last values "Baxter" "Frankie" "Johannson" "Lawton" "Peters" names L1 L2 L3 L4 L5 domain dog values "Alex" "Fido" "Kitty" "Rollie" "Sheba" names D1 D2 D3 D4 D5 end
Here is the output of the DSL code.
prints([]):- nl. prints([X|Rest]):- print(X), prints(Rest). breed("cocker spaniel"). breed("Dalmation"). breed("German sheperd"). breed("golden retriever"). breed("Greyhound"). first("Alice"). first("Carol"). first("Heidi"). first("Kay"). first("Michelle"). last("Baxter"). last("Frankie"). last("Johannson"). last("Lawton"). last("Peters"). dog("Alex"). dog("Fido"). dog("Kitty"). dog("Rollie"). dog("Sheba"). dif(X,Y):- X \= Y. go:- breed(B1), breed(B2), dif(B2,B1), breed(B3), dif(B3,B2), dif(B3,B1), breed(B4), dif(B4,B3), dif(B4,B2), dif(B4,B1), breed(B5), dif(B5,B4), dif(B5,B3), dif(B5,B2), dif(B5,B1), first(F1), first(F2), dif(F2,F1), first(F3), dif(F3,F2), dif(F3,F1), first(F4), dif(F4,F3), dif(F4,F2), dif(F4,F1), first(F5), dif(F5,F4), dif(F5,F3), dif(F5,F2), dif(F5,F1), last(L1), last(L2), dif(L2,L1), last(L3), dif(L3,L2), dif(L3,L1), last(L4), dif(L4,L3), dif(L4,L2), dif(L4,L1), last(L5), dif(L5,L4), dif(L5,L3), dif(L5,L2), dif(L5,L1), dog(D1), dog(D2), dif(D2,D1), dog(D3), dif(D3,D2), dif(D3,D1), dog(D4), dif(D4,D3), dif(D4,D2), dif(D4,D1), dog(D5), dif(D5,D4), dif(D5,D3), dif(D5,D2), dif(D5,D1), % warning: add constraints or a lot of output could be generated. prints([]), prints(["breed:"," B1=",B1," B2=",B2," B3=",B3," B4=",B4," B5=",B5]), prints(["first:"," F1=",F1," F2=",F2," F3=",F3," F4=",F4," F5=",F5]), prints(["last:"," L1=",L1," L2=",L2," L3=",L3," L4=",L4," L5=",L5]), prints(["dog:"," D1=",D1," D2=",D2," D3=",D3," D4=",D4," D5=",D5]), fail. :- solve(go).
3. End of page
by RS
admin@ycp.powersoftwo.org