Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prolog and Ruby Tasks: I. Task #1 :) (20 points) Consider the following knowledge base as in the previous assignment: nonStopFlight(la, chicago) nonStopFlight (philadelphia, la)

image text in transcribedProlog and Ruby

Tasks: I. Task #1 :) (20 points) Consider the following knowledge base as in the previous assignment: nonStopFlight(la, chicago) nonStopFlight (philadelphia, la) nonStopFlight(columbus, philadelphia). nonStopFlight (sanFrancisco, columbus). nonStopFlight(detroit, sanFrancisco) nonStopFlight(toledo, detroit) nonStopFlight (houston, sanFrancisco). You already wrote a recursive rule findFlight/2 that tells us whether we can travel by plane from one town A to another town B. This time you write a recursive rule findRoute/2 that should find the route (with zero or more airports as intermediate hops) from town A to town B. Your rule not only finds the route, it also prints the route (showing each hop seperated by a dash or so) on the computer screen. If any such route does not exist, prolog should respond "false". Run at least 2 querries and show the output (in README) you get from Prolog. Writing README carries 2 point 2. Task #2:) (20 points) Write a Prolog rule myDelete (A, List1 , List2) which deletes all occurrences of item A from Listl to produce result List2. As an example, running query myDelete(b, [b,c,d,b,c,b], Result), should give us Result = [c,d,c]. Then, extend your Prolog rule so that it asks the user for the name of the output file so that it can present the result in that output file. Test your implementation of the rule with at least 2 querries and show the results in README. Writing README carries 2 points. 3, Task #3:) Part A: (12 points) Write Prolog code which can solve any given 9x9 Sudoku puzzle. Note that the textbook has solution for the 4x4 Sudoku puzzle. You need to extend the textbook's code (i.e., sudoku4.pl on Page 104-105) and make it work for the 9x9 puzzle. Test your implementation with at least 2 querries and show the results in README. Writing README carries 1 point. Note: you may need an alternative to library rules fd_all _different and fd domain depending on your prolog system 4. Task #3:) Part B: (8 points) Write a Ruby program to do the above (i.e., which can solve any given 9x9 Sudoku puzzle). Run your Ruby program on the same instances of the puzzles as done in Part A. Measure how much time your program takes and compare that with the time taken by Prolog version. Tasks: I. Task #1 :) (20 points) Consider the following knowledge base as in the previous assignment: nonStopFlight(la, chicago) nonStopFlight (philadelphia, la) nonStopFlight(columbus, philadelphia). nonStopFlight (sanFrancisco, columbus). nonStopFlight(detroit, sanFrancisco) nonStopFlight(toledo, detroit) nonStopFlight (houston, sanFrancisco). You already wrote a recursive rule findFlight/2 that tells us whether we can travel by plane from one town A to another town B. This time you write a recursive rule findRoute/2 that should find the route (with zero or more airports as intermediate hops) from town A to town B. Your rule not only finds the route, it also prints the route (showing each hop seperated by a dash or so) on the computer screen. If any such route does not exist, prolog should respond "false". Run at least 2 querries and show the output (in README) you get from Prolog. Writing README carries 2 point 2. Task #2:) (20 points) Write a Prolog rule myDelete (A, List1 , List2) which deletes all occurrences of item A from Listl to produce result List2. As an example, running query myDelete(b, [b,c,d,b,c,b], Result), should give us Result = [c,d,c]. Then, extend your Prolog rule so that it asks the user for the name of the output file so that it can present the result in that output file. Test your implementation of the rule with at least 2 querries and show the results in README. Writing README carries 2 points. 3, Task #3:) Part A: (12 points) Write Prolog code which can solve any given 9x9 Sudoku puzzle. Note that the textbook has solution for the 4x4 Sudoku puzzle. You need to extend the textbook's code (i.e., sudoku4.pl on Page 104-105) and make it work for the 9x9 puzzle. Test your implementation with at least 2 querries and show the results in README. Writing README carries 1 point. Note: you may need an alternative to library rules fd_all _different and fd domain depending on your prolog system 4. Task #3:) Part B: (8 points) Write a Ruby program to do the above (i.e., which can solve any given 9x9 Sudoku puzzle). Run your Ruby program on the same instances of the puzzles as done in Part A. Measure how much time your program takes and compare that with the time taken by Prolog version

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

b. Is meaning dependent upon major tonal variations?

Answered: 1 week ago