程序代写代做代考 algorithm python scheme data structure Excel prolog Augustana Computing Science 370 Assignment #6

Augustana Computing Science 370 Assignment #6
Goals:
• To learn the techniques of logic programming.
• To be able to specify predicates in a declarative programming language.
• To understand the list-handling capabilities of Prolog
References:
Prolog resources from the course outline.
Instructions:
Write a SWI-Prolog program to solve Santa’s Money Making Puzzle:
Unbeknownst to most of us, Santa still requires money to obtain the raw resources to make all the toys for Christmas. Aside from being skilled toy-makers, Santa’s elves are also incredible academics and are always working on new textbooks, except during the very busy Autumn preceding the even busier Christmas season. Over the past number of years, each of Santa’s elves (whose names are Alabaster Snowball, Bushy Evergreen, Missie Toe, Pepper Minstix, Shinny Upatree, Sugarplum Mary, and Wunorse Openslae) has published a textbook in their area of expertise. These textbooks include Algorithms for Parallel Reindeer, Data Structures for Best Cookies, Scheme for Smarties, Ethics of Present Delivery, Discrete Math for Toy- Making, Calculus Most Irrelevant, and North Pole Algebra. These textbooks are sold, for prices of $250, $300, $350, $400, $450, $500, and $550 depending on the textbook, to students to aid in the learning of critical subject areas at the University of Alberta. The elves completed the textbooks during various summers in the years 2012, 2014, 2015, 2017, 2018, 2019, and 2020. University students have found the textbooks to be of excellent quality, and the price to be most reasonable.
The following facts are known about the textbooks and the elves who wrote them:
1. North Pole Algebra costs $50.00 less than the textbook published in 2012.
2. Ethics of Present Delivery costs $150.00 less than North Pole Algebra.
3. The $500.00 title, the textbook written by Pepper Minstix, the textbook written
by Shinny Upatree, the textbook that was published in 2018, the textbook written
by Wunorse Openslae and Calculus Most Irrelevant are all unique textbooks.
4. The textbook that was published in 2020 and the one that cost $550.00, were
written by either Missie Toe or Sugarplum Mary.
5. Ethics of Present Delivery costs less than the textbook that was published in
2017.
6. The textbook from 2019 costs $100.00 more than Scheme for Smarties.
7. The textbook that was published in 2018 was written by Missie Toe.

8. The textbook written by Pepper Minstix costs $100.00 less than the textbook that was published in 2014.
9. Alabaster Snowball was not the auther of Discrete Math for Toy-Making nor of the textbook that costs $400.00.
10. Of the textbook, Data Structures for Best Cookies, and the title from 2017, one was written by Pepper Minstix and the other costs $400.00.
11. The textbook that was published in summer 2020 costs $50.00 more than the one written by Shinny Upatree.
Your program must determine which elf wrote which textbook, during which year, and how much money it costs for one copy of that textbook.
For full marks, implement your solution such that the puzzle can be solved by the query
?- solve.
Your Prolog program should format the results in tabular form, with the headings and spacing illustrated in the following table.
Elf

Alabaster Snowball
Bushy Evergreen
Missie Toe
Pepper Minstix
Shinny Upatree
Sugarplum Mary
Wunorse Openslae
Textbook
——–
Data Structures for Best Cookies
Discrete Math for Toy-Making
Scheme for Smarties
Calculus Most Irrelevant
Ethics of Present Delivery
North Pole Algebra
Algorithms for Parallel Reindeer
Year Cost
—- —-
2015 $550.00
2017 $400.00
2012 $350.00
2020 $500.00
2018 $400.00
2019 $450.00
2014 $250.00
Note that the body of this table is not a correct solution to the puzzle. However, the table shows that the elves’ names should be alphabetical and left-aligned and the titles, years, and costs should be aligned.
If you do not have time to do the appropriate formatting of the results, you may submit, for reduced marks (-10%), a program which presents the correct result as a list of sublists of the form:
[[elf1, textbook1, year1, cost1], [elf2, textbook2, year2, cost2], … ]
It would have the same data as illustrated in the table above in the following form:
[[alabasterSnowball, dataStructuresForBestCookies, 2015, 550], [bushyEvergreen, discreteMathForToyMaking, 2017, 400], [missieToe, schemeForSmarties, 2012, 350], … ]
Hints about formatting/printing:
The header is easily generated using the write/1 predicate, since the argument to write may be a single-quoted (Python-like) constant, as in
write(‘This is a string constant.’).
2

Remember that, in Prolog, the name of a constant can be capitalized and include spaces if the name is enclosed in single quotes, while a string in double quotes is equivalent to a list of integers (ASCII). For example:
write(“Hello”).
results in
[72, 101, 108, 108, 111].
SWI-Prolog also provides a writef/2 predicate which implements formatted output. This predicate is deprecated (replaced by format), but you may use it anyway. The predicate resembles C’s printf function in that the first argument is a format string. However, the second argument is a list of the arguments to be inserted at the points specified by escape sequences in the format string. For example
writef(‘%5l %10r’, [hi, 25]).
prints hi in a field width of 5, left aligned (that is a 5 el) followed by 25 in a field width of 10 and right aligned: hi 25
writef handles any kind of input, including atoms, numbers, and strings.
Some items to consider in your implementation:
1) You must use a logic programming style.
2) You must set up the constraints so that Prolog solves the problem, by finding the solution.
You cannot just give Prolog the correct answer, should you happen to discover it, nor
should you use your own intelligence to guide Prolog too much.
3) You may want explicit statements giving the string equivalent of an elf or a textbook title,
so that the capitalization is easily handled in the final report of the solution.
4) You are not allowed to use the cut (!) in your program, nor the or operator (;).
5) The following list contains the built-in predicates, functions and operators you may use (all
others must be cleared with the instructor):
a. dynamic, assert, asserta, assertz, retract, retractall
b. Any arithmetic operators
c. Any comparison operators
d. is
e. random
f. write, nl, get0, writef, read
g. and operator (,), not operator (+)
h. member, reverse, append
Marking:
Due to the large number of students in our Computing Science program, it is no longer possible for the instructor to run each program individually. This means that your code (+ testing) must speak for itself, and convince the instructor that your program works. You must hand in testing of your program. The instructor will run some programs each time. These will be chosen at random or if it seems the code does not match the testing submitted. If the code does not match the testing that is submitted, then a mark of 0 (zero) will be awarded for the assignment.
Considerations when marking:
1) Correctness (must be in Prolog, working, no plagiarism, testing submitted)
3

2) Documentation (Easy to read and follow, indentation, file header [name, date, summary], program subdivision, subprogram headers [summary, parameter, return], descriptive variable names including method names, no useless code, inline useful comments [no code translation], main steps are clear [pop out], recursion levels reasonable, organization)
3) Style (includes design, efficiency, appropriate/idiomatic use of the Prolog programming language)
A program with syntax errors will attain a mark of 50% at best, depending on documentation, style, and how much of the program appears finished.
Hand in:
1) Your Prolog file.
2) .pdf of your Prolog file
3) .pdf of one testing run.
4

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *