ECOO '15 R1 P1 - When You Eat Your Smarties

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type

When I eat my Smarties I always eat the red ones last. I separate them into their color groups and I start by eating the orange ones, then blue, green, yellow, pink, violet, brown and finally red. The red ones are the best, so I eat them slowly one at a time. The other colors I eat quickly by the handful (my hand can hold a maximum of 7 Smarties). I always finish all the Smarties of one color before I move on to the next, so sometimes the last handful of a color isn't a full one.

But wait, there's more! I have turned my Smartie-eating into a science. I know it always takes me exactly 13 seconds to eat a handful of non-red Smarties and I adjust my chewing rate so that I always take 13 seconds even if my hand is not completely full. When I eat the red Smarties I like to take my time, so it takes me exactly 16 seconds to eat each one. I have a big box of Smarties. After I've finished sorting the colors, how long will it take me to eat them?

The input will contain 10 test cases. Each test case will start with N lines (50 \le N \le 200), where each line holds the color of a single Smartie in lower case. Then the last line will read end of box meaning there are no more Smarties in the box for that test case.

Your program should output a single line for each test case indicating how long (in seconds) it will take me to eat the entire box according to the rules given above. Note that the sample input below only contains 1 test case, but the real data files will contain 10.

Sample Input

red
brown
brown
violet
blue
pink
blue
blue
pink
brown
yellow
brown
pink
violet
green
yellow
red
orange
orange
blue
brown
pink
red
red
red
brown
orange
orange
green
red
orange
violet
blue
pink
yellow
pink
brown
orange
green
red
blue
yellow
green
orange
brown
orange
pink
violet
brown
red
end of box

Sample Output

245

Note: Only 1 case is shown in this sample.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org


Comments


  • 0
    Hackerman_567  commented on Jan. 5, 2023, 12:16 a.m.

    Hey guys. Does anyone know the input for the other test cases? Are they specific test cases or do you make your own?


    • 0
      fireheartjerry  commented on Jan. 6, 2023, 10:39 a.m.

      You can find a link to 2015 test data here, note that it automatically starts downloading.


  • 0
    zhaosh84  commented on Dec. 25, 2022, 7:06 p.m. edited

    hello, I don't see any logical errors in my code and I definitely get the numbers of each colour right. I also passed the sample input. i know that I eat red gummies one at a time and other same colours 7 at a time(they don't have to be 7 full). the judge says that I'm 5/50 on both test cases. can someone help me


    • 1
      valegrete  commented on Dec. 26, 2022, 9:56 p.m.

      Look further down this thread. You have to write the program to handle all ten cases, not just a single case. This threw me for a loop, too.


  • 1
    chrismilne  commented on Aug. 31, 2022, 10:36 a.m.

    I'm getting the correct answer when I submit the sample, but it's rejecting my solution. Can anyone see what my mistake is? Thanks


  • -1
    electrobird  commented on Aug. 4, 2022, 4:39 p.m. edited

    First time I have a problem that I can't really understand where the error is. Everything looks fine on my end and I am getting the expected (245) results when running locally and was careful to loop the whole program ten times to accommoddate all the test cases. The output is clipped, so I can't tell where the error is and I am finding impossible to troubleshoot.


  • 0
    b4n4n4p4nd4  commented on Aug. 3, 2022, 3:34 p.m.

    I have an accepted solution if I trap a KeyError. They're clipping the output so it's hard to diagnose, as the sample doesn't generate any error. KeyError suggests there's a line which isn't one of the colours in lowercase, or "end of box". Very weird.


  • 0
    datacobra  commented on May 19, 2022, 5:20 a.m.

    I try this now for several days and don't find the answer...

    I hope someone can give me a hint.

    When I try the sample input I get 232. So there are 13 seconds missing.

    I counted the sample input and found 8 times red smarties and a total of 50 smarties which is exactly 232 and not 245 seconds.


    • 0
      jeano  commented on Sept. 4, 2022, 4:28 p.m.

      For a total of 50 smarties :

      • 8 red smarties is 8*16 = 128
      • 42 non-red smarties is (42/7)*13 = 78

      78 + 128 = 206 seconds

      There has to be an error with the the number of smarties in that box.


      • 1
        wertiop1  commented on Oct. 21, 2022, 8:53 p.m.

        It says that you can only eat smarties of the same color in handfuls.


  • 2
    sashimiP  commented on April 27, 2022, 7:56 a.m.

    mind the line "The red ones are the best, so I eat them slowly ONE at a time."! I spend an hour and a half pulling my hair wondering what am I missing, before I realized that the red ones, take 16 seconds each to eat!


  • 3
    jasperfu1234  commented on April 17, 2022, 5:03 p.m.

    I used a dictionary to make this problem much simpler. :)


  • -4
    solverbot  commented on April 12, 2022, 10:24 a.m.

    Make sure to strip the inputs of any new lines, spaces and ensure your algorithm doesn't count "end of box" in the eating time.


  • 7
    ThePeeps191  commented on Feb. 12, 2022, 3:42 p.m.

    Be Sure to for loop your code 10 times ;)


  • 22
    nicholas_heaton  commented on Aug. 2, 2021, 5:46 p.m.

    Caution, pay extra attention to the 'The input will contain 10 test cases.'

    This test goes against the typical convention i've see on here, and expects you to process all 10 test cases in the same execution. If you are only getting the first test case right, and all others wrong, you likely made the same mistake/assumption that I did and only processed the first test case.


    • 1
      whammydiver  commented on March 15, 2022, 9:17 p.m.

      Totally missed this.


  • 1
    Yuting9  commented on April 5, 2015, 5:03 p.m.

    When I count and calculate the sample, it gives me 258. Is there something really obvious that I'm missing?


    • -1
      bobhob314  commented on April 5, 2015, 5:46 p.m.

      "I always take 13 seconds even if my hand is not completely full."

      Your answer is 13 more than the required answer. (Hint acquired?)