CCC '12 J2 - Sounds fishy!

View as PDF

Submit solution

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

Problem type
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 "Fish At 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

Comments


  • 0
    R_G  commented on Feb. 4, 2024, 2:11 p.m. edited

    this one wasn't as hard as other j2s. Just do a bunch of if else statements


  • 0
    NorthManDude  commented on Dec. 11, 2023, 10:06 a.m.

    Shouldn't Fish Diving and Fish Rising be the other way around? If the depth gets bigger with each reading it seems like the fish is going down, not up.


    • 0
      qt  commented on Dec. 11, 2023, 1:41 p.m.

      The depth reading is the distance between the fish and the bottom of the lake


  • -2
    22yeetz22  commented on Oct. 31, 2022, 9:31 p.m.

    Can someone help with my code I have no idea why it's failing the last case. https://dmoj.ca/submission/4994013


  • 2
    Misaka  commented on Oct. 7, 2022, 9:41 p.m.

    A kind tip:

    Remember to check your output. Don't forget those upper-case letters.


  • 23
    iiGam_r  commented on Feb. 17, 2021, 4:34 p.m.

    Hints for anyone coming across this comment:

    • For the "No fish", look closely at what it says!
    • Look at the example for the pattern sequence for both 1st and 2nd pattern! Once you figure it out, it should be easy!
    • And last, but not least, for the "Fish At Constant Depth", don't overthink it! It's easier than it seems!

    Hope these hints helped you! Upvote if it did! Good luck!


  • 7
    SpicyEnch14  commented on Jan. 20, 2020, 5:56 p.m.

  • -13
    12weareunited  commented on Aug. 30, 2018, 6:48 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 8
      segfault  commented on Aug. 30, 2018, 8: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.