Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Optimizing if conditional statement

Is there a better way to write the below?

if ((A && B) || (A && B && C)) { ... }

which means I cannot do

if ((A && B) || C) { ... }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use logical rules to simplify the statement:

(A && B) || (A && B && C)

Factorizing the common part (A && B) you get:

(A && B) && (true || C)

And of course true || C is always true so that entire group becomes a "don't care" and can be discarded. That leaves just:

A && B

There are other ways to arrive at the same result. In this case, even writing out a basic truth table would have made it pretty obvious.

For more complicated expressions, the use of a Karnaugh Map can be helpful.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!