[RUBY] Also complicated conditional branching

I would like to play a simple interrogation game. The suspect is a and b, both testifying to be true, or true if both are false testimony. If one is witnessing the truth, but the other is witnessing a lie, False. I would like to make a program like this.

First, define the method.

def investigation(a, b)

end

After that, it seems good to describe the conditional branch. We will describe by combining the following logical operators.

#true if both a and b are true
a && b

#true if either a or b is true
a || b 

#false if a is true, true if a is false
!a

We will describe the conditional branch processing.

def investigation(a, b)
  if (a && B ) || (!a && !b)
    puts "True"
  else
    puts "False"
  end
end

You have now created a game.

Recommended Posts

Also complicated conditional branching
A little complicated conditional branching
Conditional branching of numbers
Ruby study memo (conditional branching)
[Ruby] Conditional branching Conditional expression order
java (conditional branching and repetition)
Conditional branching with a flowing interface
Java study # 4 (conditional branching / if statement)
[Java] Conditional branching is an if statement, but there is also a conditional operator.
[Java ~ Conditional branching / Iterative processing ~] Study memo (3)