TORONTO KIDS COMPUTER CLUB | PMCA Sunday 14:00 Python Homework 20.12.27.
18889
post-template-default,single,single-post,postid-18889,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Sunday 14:00 Python Homework 20.12.27.

30 Dec PMCA Sunday 14:00 Python Homework 20.12.27.

Question 1:
Canada Cosmos Control has received a report of another incident. They believe that an alien has illegally entered our space. A person who witnessed the appearance of the alien has come forward to describe the alien’s appearance. It is your role within the CCC to determine which alien has arrived. There are only 3 alien species that we are aware of, described below:

  • TroyMartian, who has at least 3 antenna and at most 4 eyes;
  • VladSaturnian, who has at most 6 antenna and at least 2 eyes;
  • GraemeMercurian, who has at most 2 antenna and at most 3 eyes.

Input Specification
The user will be prompted to enter two numbers. First, the user will be prompted to enter the number of antenna that the witness claimed to have seen on the alien. Second, the user will be prompted to enter the number of eyes seen on the alien.

Output Specification
The output will be the list of aliens who match the possible description given by the witness. If no aliens match the description, there is no output.

Sample Session 1 (with output shown in text, user input in italics)
How many antennas?
4
How many eyes?
5
VladSaturnian

Sample Session 2
How many antennas?
2
How many eyes?
3
VladSaturnian
GraemeMercurian

Sample Session 3
How many antennas?
8
How many eyes?
6
(Note: there is no output for Sample Session 3)



Question 2:
A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:

  • there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call “Fish Rising”), or
  • there are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call “Fish Diving”), or
  • there are four consecutive depth readings which are identical (which we will call “Constant Depth”).

All other readings will be considered random noise or debris, which we will call “No Fish.”

Your task is to read a sequence of depth readings and determine if the alarm will sound.

Input Specification
The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.

Output Specification
The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should be Fish At Constant Depth. Otherwise, the output should be No Fish.

Sample Input 1
30
10
20
20

Output for Sample Input 1
No Fish

Sample Input 2
1
10
12
13

Output for Sample Input 2
Fish Rising


Question 3:

You supervise a small parking lot which has N parking spaces. Yesterday, you recorded which parking spaces were occupied by cars and which were empty. Today, you recorded the same information. How many of the parking spaces were occupied both yesterday and today?


Input Specification:
The first line of input contains the integer N (1 ≤ N ≤ 100). The second and third lines of input contain N characters each. The second line of input records the information about yesterday’s parking spaces, and the third line of input records the information about today’s parking spaces. Each of these 2N characters will either be “C to indicate an occupied space or “.” to indicate it was an empty parking space.


Output Specification:
Output the number of parking spaces which were occupied yesterday and today.


Sample Input 1:
5
CC..C
.CC..
Output for Sample Input 1:
1

Explanation of Output for Sample Input 1:
Only the second parking space from the left was occupied yesterday and today.


Sample Input 2:
7
CCCCCCC
C.C.C.C
Output for Sample Input 2:
4

Explanation of Output for Sample Input 2:
The first, third, fifth, and seventh parking spaces were occupied yesterday and today

No Comments

Sorry, the comment form is closed at this time.