Easy

Once Mary heard a famous song, and a line from it stuck in her head. That line was "Will you still love me when I'm no longer young and beautiful?". Mary believes that a person is loved if and only if he/she is both young and beautiful, but this is quite a depressing thought, so she wants to put her belief to the test.

Knowing whether a person is young, beautiful and loved, find out if they contradict Mary's belief.

A person contradicts Mary's belief if one of the following statements is true:

  • they are young and beautiful but not loved;
  • they are loved but not young or not beautiful.

Example

  • For young = true, beautiful = true, and loved = true, the output should be
    willYou(young, beautiful, loved) = false.

    Young and beautiful people are loved according to Mary's belief.

  • For young = true, beautiful = false, and loved = true, the output should be
    willYou(young, beautiful, loved) = true.

    Mary doesn't believe that not beautiful people can be loved.

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] boolean young

  • [input] boolean beautiful

  • [input] boolean loved

  • [output] boolean

    • true if the person contradicts Mary's belief, 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 willYou(bool young,bool beautiful,bool loved)
{
	return loved&&!(young&&beautiful) || !loved&&(young&&beautiful);
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Kill K-th Bit  (0) 2020.04.07
<Codesignal> Metro Card  (0) 2020.04.07
<Codesignal> Tennis Set  (0) 2020.04.07
<Codesignal> Arithmetic Expression  (0) 2020.04.07
<Codesignal> Is Infinite Process?  (0) 2020.04.07

+ Recent posts