## CCC '12 J2 - Sounds fishy!

View as PDF

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### Canadian Computing Competition: 2012 Stage 1, Junior #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

• commented on Jan. 25, 2020, 5:09 p.m.

remember you should not output"constant depth", it actually requires you to output "Fish At Constant Depth"

• commented on Jan. 20, 2020, 12:56 p.m.
• commented on Oct. 17, 2018, 11:47 a.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Oct. 17, 2018, 12:18 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Oct. 17, 2018, 12:12 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Aug. 31, 2018, 11:28 p.m.

Thanks for the help

• commented on Aug. 30, 2018, 2:48 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Aug. 30, 2018, 4:46 p.m.

The first combination is simply that the first number must be strictly smaller than the second number, the second number strictly smaller than the third number, and the third number strictly smaller than the fourth number.

Keep in mind that there are 3 more conditions which you need to watch out for.

• commented on March 9, 2018, 9:26 a.m.

In the description of the question it says "Constant Depth" is one of the alarm triggers. In the output specification it says "Fish At Constant Depth" which is the actual required output. The description should be changed to be consistent with the actual output specification.

• commented on Jan. 20, 2020, 4:23 a.m.

I like how the most important comment is at the bottom.