Logic Problem Set 1

Logic.1 Cigar Party

When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Write a Raptor program that will check if the party is successful and display "Successful Party" if the party with the given values is successful, or "Not a Success" otherwise.

Your program should take the number of cigars and weekday as input. The week day input is taken as 1 for Monday, 2 for Tuesday, ..., 7 for Sunday. Weekends are Saturday and Sunday, i.e., 6 and 7. The following is the test cases table. Your program should be tested on these test cases. Also, Identify 5 more test cases and test them on your program.

Test Case
Cigars Input
Weekday Input
Program Output
1 30 2 Not a success
2 50 3 Success
3 70 6 Success

Solutions:

python

raptor

Logic.2 Date Fashion

You and your date are trying to get a table at a restaurant. Write a Raptor program to check if you can get the table. Take the variable you is the stylishness of your clothes, in the range 0..10, and date is the stylishness of your date's clothes as inputs. The result getting the table is either 0=no, 1=maybe, or 2=yes. If either of you/date is very stylish, 8 or more, then the result is yes. With the exception that if either of you/date has style of 2 or less, then the result is no. Otherwise the result is maybe.

Test Case
You
Date
Program Output
1 5 10 2
2 5 2 0
3 5 5 1

Solutions:

python

raptor

Logic.3 Squirrel Play

The squirrels in Hyderabad spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Write a Raptor program that takes the temperature and isSummer (1 if it is summer and 0 otherwise) as input, and displays "Squirrels play" if they play and "Squirrels don't play" otherwise.

Test Case
Temperature
Is Summer
Program Output
1 70 0 Squirrels play
2 95 0 Squirrels don't play
3 95 1 Squirrels play

Solutions:

python

raptor