알고리즘/codefights

15>willYou

Diademata 2019. 2. 24. 13:37
반응형

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.


code>>


bool willYou(bool young, bool beautiful, bool loved) {


    return (young & beautiful) ^ loved;

}



반응형

'알고리즘 > codefights' 카테고리의 다른 글

Challenge>fibonacciIndex  (0) 2019.03.06
16>metroCard  (0) 2019.02.24
14>tennisSet  (0) 2019.02.24
13>arithmeticExpression  (0) 2018.05.20
12>isInfiniteProcess  (0) 2018.05.19