Logic Problem Set 3

Part 1 - Raptor Programs

Logic.7 In 1 to 10

Given a number n, return true if n is in the range 1..10, inclusive. Unless outsideMode is true, in which case return true if the number is less or equal to 1, or greater or equal to 10. Add 5 more test cases.

Test Case
Number Input
Outside Mode
Program Output
1 5 false true
2 11 false false
3 11 true true

Solutions:

python

raptor

Logic.8 Near Ten

Given a non-negative number, return true if it is within 2 of a multiple of 10. Note: (A % B) is the remainder of dividing A by B, so (7 % 5) is 2. Add 5 more test cases.

Test Case
Number
Program Output
1 12 true
2 17 false
3 19 true

Solutions:

python

raptor

Logic.9 Teen Sum

Given 2 ints, a and b, return their sum. However, "teen" values in the range 13..19 inclusive, are extra lucky. So if either value is a teen, just return 19. Add 5 more test cases.

Test Case
Day of Week
Vacation
Program Output
1 3 4 7
2 10 13 19
3 13 2 19

Solutions:

python

raptor