Logic Problem Set 5

Part 1 - Raptor Programs

Logic.13 In Order

Given three ints, A B C, display true if they obey the following rule. B and C both have the constraint that they must be greater than the value immediately to their left, such as with 2 5 11, or 5 6 7, but not 6 5 7 or 5 7 7. However, with the exception that if constraint on b is relaxed, B does not have to follow the constraint. Add 5 more test cases.

Test Case
A

B

C B Relax
Program Output
1 1 2 4 No True
2 1 2 1 No False
3 3 2 4 No False

Solutions:

python

raptor

Logic.14 In Order Equal

Given three ints, a b c, return true if they are in strict increasing order, such as 2 5 11, or 5 6 7, but not 6 5 7 or 5 5 7. However, with the exception that if equal constraint is relaxed, equality is allowed, such as 5 5 7 or 5 5 5. Add 5 more test cases.

Test Case
a
b
c Equality Relaxed
Program Output
1 2 5 11 No False
2 5 7 6 No False
3 5 5 7 Yes True

Solutions:

python

raptor

Logic.15 Last Digit

Given three ints, a b c, display true if two more of them have the same rightmost digit. The ints are non-negative. Note: the % "mod" operator computes the remainder, e.g. 17 % 10 is 7. Add 5 more test cases.

Test Case
a
b
c
Program Output
1 23 19 13 True
2 23 19 12 False
3 23 19 3 True

Solutions:

python

raptor