-
Notifications
You must be signed in to change notification settings - Fork 4
/
15_willYou.go
44 lines (32 loc) · 1.45 KB
/
15_willYou.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
Challenge: Will You?
https://codefights.com/arcade/code-arcade/at-the-crossroads/jZ4ZSiGohzFTeg4yb/description
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
[time limit] 4000ms (go)
[input] boolean young
[input] boolean beautiful
[input] boolean loved
[output] boolean
true if the person contradicts Mary's belief, false otherwise.
**/
func willYou(young bool, beautiful bool, loved bool) bool {
if young && beautiful && (!loved) {
return true
}
if loved && !(beautiful && young) {
return true
}
return false
}