Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

88
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda