Question 1: Riding the Sine Wave
The Fantastic Factorial Fun Park has a popular roller coaster (called the Sine Wave) with a somewhat complex set of rules for who can go on it. They have tasked you with writing a function that can tell people whether they can ride it or not. The function has three parameters: the persons height in whole cm, age in whole years and a Boolean indicating if they are accompanied by an adult. It can return three possible string messages: Sorry, you cannot ride if the rules exclude a person from riding the Sine Wave; Find an adult if the person (child in this case) can ride as long as they come back with an adult; and You can ride if they are allowed to ride the Sine Wave.
The rules are as follows:
Anyone less than 110cm or taller than 200cm cannot ride
Anyone younger than 6 cannot ride
If a child aged between 6 and 9 (inclusive) wishes to ride, they can do so if they are accompanied by an adult, otherwise they are told that they must Find an adult Everyone else is allowed to ride the roller coaster
Your task is implement the rules above by completing the implementation of q1_sine_wave_check in the assignment script le. It is currently very pessimistic, telling all patrons that they are not allowed on. Complete the implementation by using any combination of if statements and Boolean expressions. The if statements may be nested as you see t.
Full marks will be given to solutions that use as few tests as possible. A solution that works for all cases, but which repeats a test or implements each rule completely separately, will get 1 mark. A solution that works for only many possible inputs will receive 0.5 marks, while a solution that works rarely or not at all will receive no marks.
Sample Test Data
Question 2: Implementing predicates as functions
There are stub (i.e., incomplete) implementations of each of these predicates as functions in the assignment script le (named q2_a through q2_d). Replace None in each of these stub functions with an implementation of the predicates below as they are written. The functions already have the required parameters listed. All parameters are Boolean.
- (*) (ab)(ab)
- (*) a(bcd)
- (ab)(ac)
- aa
Question 3: Simplifying predicates
For each subpart (a)(d) in Question 2, write a simpli ed implementation. There are stub functions named q3_a through q3_d for you to complete. KMA155 students must attempt at least parts (a) and
(b).
Question 4: The Letter Detector
The ACME Logic Company has a simple object recognition system that can identify when a particular arrangement of horizontal and vertical lines represents a letter (not which letter, only that it is a letter). They have a camera that can detect four di erent lines: horizontal lines either at the top or bottom of an image, and vertical lines at the left or right. Although the image may be hand-drawn, their detector sees it as if it were like part of a digital display, like this: a
d b
c
To determine if the arrangement of lines looks like a letter they use the following truth table (for convenience the truth table is presented using 0 for False and 1 for True, but the function accepts four Boolean variables ad and returns a Boolean value). The Letter column is only for information; the function will not attempt to actually identify the letter.
| a | b | c | d | Output | Letter |
| 0 | 0 | 0 | 0 | 0 | |
| 0 | 0 | 0 | 1 | 1 | I |
| 0 | 0 | 1 | 0 | 0 | |
| 0 | 0 | 1 | 1 | 1 | L |
| 0 | 1 | 0 | 0 | 1 | I |
| 0 | 1 | 0 | 1 | 0 | |
| a b c d | Output | Letter | |||
| 0 | 1 | 1 | 0 | 0 | |
| 0 | 1 | 1 | 1 | 1 | U |
| 1 | 0 | 0 | 0 | 0 | |
| 1 | 0 | 0 | 1 | 0 | |
| 1 | 0 | 1 | 0 | 0 | |
| 1 | 0 | 1 | 1 | 1 | C |
| 1 | 1 | 0 | 0 | 0 | |
| 1 | 1 | 0 | 1 | 0 | |
| 1 | 1 | 1 | 0 | 0 | |
| 1 | 1 | 1 | 1 | 1 | O or D |
You have two tasks:
- (*) Transfer the information in the truth table to the Karnaugh map stored in q4_kmap in the script le, treating the columns as ab and rows as cd. q4_map is a list of lists, but you can treat it as if it were a table: replace the appropriate locations with 1s. Tip: Draw the Karnaugh map on paper rst and identify the groups. You wont be able to show the groups in the script le, but this will help with part (b). (0.5 marks)
- (*) Replace the complicated Boolean expression currently in q4_acme_letter_detector with a simpli ed expression determined from your Karnaugh map. (1 mark)

![[Solved] KIT103 Assignment2-Riding the Sine Wave](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] KIT103 Assignment4- Decode Linux Permissions](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.