Ad
  • Custom User Avatar

    As said in description:

    A team can know the bonus amount of its adjacent team, if the
    score of the adjacent team is lower than itself.

    This means the first team (team who scored 30) will know the bonus amount of the second team (team who scored 20), the second team will know the amount of bonus from the third team (team who scored 10). Also said in description that:

    If a team finds that its bonus is no higher than the adjacent team whose
    score is lower than itself, the team will not be satisfied

    First we know that the third team knew none of the other teams' score, therefore they get the lowest of 1 bonus. Secondly, the second team knew the score of third team (which means second team have a higher amount of score), therefore they needed a bonus amount higher than 1, which is 2. We can also use the same logic to get the amount of bonus for the first team, they needed a bonus higher than 2, which is 3. Then we add all the bonuses together to get:

    1+2+3=6k, so the answer is 6 for minimum bonus. Sorry if my explaination isn't clear enough :)

  • Default User Avatar

    glad you enjoyed it!

  • Default User Avatar

    Thanks for the comment ~ inspired to create an anniversary celebration themed kata, I strove to create a simple real-world task that could be easily visualized.

  • Custom User Avatar
  • Default User Avatar

    Thank you very much,that was very helpful.Im beginner and i wouldnt consider this approach.

  • Custom User Avatar

    Your solution is too slow, especially for more difficult/larger inputs. The computational complexity of some problems grows rapidly with input size and sometimes trivial, naïve solutions pass for small inputs, but are not sufficiently performant for more challenging scenarios. You probably need to think of a better approach: some optimizations might help, but also might not. In the latter case, you probably need to think of a better algorithm.

    Tl;dr, you need a faster code. Most passed solutions can solve this kata within 1000ms.

    Troubleshooting Your Solution

    (Hint: try to look for pattern instead of brute-forcing)

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar
    • Description should be language-agnostic

    • Probably better to use KaTeX for the mathematical part of the code

  • Custom User Avatar

    Thanks @cod3abuser! But technically it's not a good solution hahaha

  • Custom User Avatar

    Thanks for the nice kata!

  • Custom User Avatar
  • Default User Avatar

    i like your solution!! ;)

  • Default User Avatar

    oh, sorry. it was a typo. it meant to say greater than 0. Glad you enjoy it though!

    Edit: I've changed it to postive integer instead.

  • Custom User Avatar

    Hi, this is a very fun kata but there is something that is unclear to me in the description. You said:

    The number inside the bracket will always be greater than 1.

    But there are test cases where the number inside the bracket is equal to 1, mind changing it to greater or equal to 1? Many thanks.

  • Loading more items...