Sounds fishy!
InterviewTime limit2sMemory limit512 MB
Read four depth readings and print Fish Rising, Fish Diving, Fish At Constant Depth, or No Fish based on their ordering.
- Level
Easy1 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
A fish-finder is a device anglers use to locate fish in a lake. When it finds a fish, it sounds an alarm. It relies on depth readings to decide whether to sound that alarm. The fish-finder decides a fish has swum past if:
- four consecutive depth readings form a strictly increasing sequence (such as 3 4 7 9), which we call "Fish Rising", or
- four consecutive depth readings form a strictly decreasing sequence (such as 9 6 5 2), which we call "Fish Diving", or
- four consecutive depth readings are all identical, which we call "Constant Depth".
Every other reading is treated as random noise or debris, which we call "No Fish".
Read the sequence of depth readings and determine whether the alarm will sound.
Input
The input is four positive integers, the depth readings, one integer per line.
Output
Print exactly one of four results. If the readings are strictly increasing, print Fish Rising. If they are strictly decreasing, print Fish Diving. If they are all identical, print Fish At Constant Depth. Otherwise, print No Fish.