I need help on control Flow Ruby | Combining Boolean Operators


#1
# boolean_1 = (3 < 4 || false) && (false || true)
boolean_1 = (3 && (true || true)) && 3


# boolean_2 = !true && (!true || 100 != 5**2)
boolean_2 = (x && (true || true)) && z


# boolean_3 = true || !(true || false)
boolean_3 = (3 && (true || false)) && 3

thats what I got but still failed :frowning: pls help


#2

You need to logically (in your head) work out whether each expression that begins with "#", is true or false. Once you determined that, then set each boolean to true or false respectively.

No need to get at complicated as you have.


#3

k ill try :smile: to to It, it might not wrok becues im bad at math but


#4

can I get an Ex. pls


#5

These are just simply logic problems.

Just work each each part before && and || parts, and write down whether those parts are true or false then work out the next part(s).

Once you broken it down to something like true && false or false || true (or something), then you can simplify it to one word true or false by using conditional rules you've learned earlier.

Recall that if something is true in an && expression, and something else in the same expression is false then the entire expression becomes false since you are explicitly checking that each sub-expression is true by using and. Likewise, recall that if any part of an || expression is true, then checking stops and the entire expression becomes true due to explicitly checking that any part of the conditional is true.

Does that make sense?

So, for example:

( ((8 > 5 || 2 < 3) && (true || false)) && (!true || 1000 != 50*4) )

This can thus be simplified to:

( ((false || true) && (true || false)) && (false || true) )

Then

( ((true) && (true)) && (true) )

Then

( ((true)) && (true) )

Finally:

( true )

Does that make sense?


#6

yes actuly thx :smiley: for the Ex.


#7

im going to stuby This if need to for later work maby :smile:


#8

I have the same problem. None of the replies here got me passed the exercise.