Easy

You are playing an RPG game. Currently your experience points (XP) total is equal to experience. To reach the next level your XP should be at least at threshold. If you kill the monster in front of you, you will gain more experience points in the amount of the reward.

Given values experience, threshold and reward, check if you reach the next level after killing the monster.

Example

  • For experience = 10, threshold = 15, and reward = 5, the output should be
    reachNextLevel(experience, threshold, reward) = true;
  • For experience = 10, threshold = 15, and reward = 4, the output should be
    reachNextLevel(experience, threshold, reward) = false.

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] integer experience

    Guaranteed constraints:
    3 ≤ experience ≤ 250.

  • [input] integer threshold

    Guaranteed constraints:
    5 ≤ threshold ≤ 300.

  • [input] integer reward

    Guaranteed constraints:
    2 ≤ reward ≤ 65.

  • [output] boolean

    • true if you reach the next level, false otherwise.

[C] Syntax Tips

// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
    char * answer = malloc(strlen(name) + 8);
    printf("This prints to the console when you Run Tests");
    strcpy(answer, "Hello, ");
    strcat(answer, name);
    return answer;
}

더보기

Solution

bool reachNextLevel(int experience,int threshold,int reward)
{
	return experience+reward>=threshold;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Is Infinite Process?  (0) 2020.04.07
<Codesignal> Extra Number  (0) 2020.04.07
<Codesignal> Phone Call  (0) 2020.04.07
<Codesignal> Late Ride  (0) 2020.04.07
<Codesignal> Max Multiple  (0) 2020.04.07

+ Recent posts