If you cannot come up with a formula, you can use a table for such a limited number of outcomes:
final int[][] result = new int[][] {
{ 0, 0, 1, 2 },
{ 0, 0, 2, 1 },
{ 2, 1, 3, 3 },
{ 1, 2, 3, 3 }
};
return result[one][two];
More Related Contents:
- What does if(‘;’) do and mean? [closed]
- if else statement in AngularJS templates
- Is it a bad practice to use an if-statement without curly braces? [closed]
- Method for evaluating math expressions in Java
- Is “IF” expensive?
- Code executes condition wrong?
- Can I use the range operator with if statement in Swift?
- Why the switch statement and not if-else?
- How is Swift `if let` evaluated?
- Windows batch file IF failure – How can 30000000000000 equal 40000000000?
- VB6 IIf advantage
- weird results with IF
- Is returning early from a function more elegant than an if statement?
- What is wrong with my if-statement?
- How can I implement if(x >= ‘0’ && x
- Dart null / false / empty checking: How to write this shorter?
- How can I port C++ code that uses the ternary operator to Rust?
- how to calculate reverse modulus
- Parse error: syntax error, unexpected ‘;’ [closed]
- Algorithm to find Largest prime factor of a number
- Difference between multiple if’s and elif’s?
- How do you print superscript in Python?
- Difference between “if constexpr()” Vs “if()”
- Bash if statement with multiple conditions throws an error
- What do these operators mean (** , ^ , %, //)? [closed]
- Create column with grouped values based on another column
- Confusion between C++ and OpenGL matrix order (row-major vs column-major)
- How to simplify a decimal into the smallest possible fraction?
- Ruby factorial function
- counting combinations and permutations efficiently