Rico Felix wrote:This sort of problem can be made much simpler using some logic and the Java API
Here is one proposed way you can accomplish such a task:
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
Paul Ngom wrote:which makes it too long :-)
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
DontWriteLongLines
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
Tiberius Marius wrote:Using only an if statement to verify this what is the most short condition that can be checked to identify when the digits in a 3 digits number match the digits of another 3 digits integer number (not interested if they match exactly) .
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are, however, several ways of simplifying it if you CAN use other logic. My suggestion:
1. Put the digits in Sets (java.util.Set).
2. Check the lengths of those sets. If they're different, the digits can't possibly match.
3. Put the digits in Lists (java.util.List), sort them, and check if they are identical. Hopefully, that one is self-explanatory.
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
Paul Ngom wrote:And i will say that it is better that your if statement reads:
to avoid confusion
Think it is incorrect in the sense 111 and 100 will pass the condition
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
Paul Ngom wrote:And i will say that it is better that your if statement reads:
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
This I think works but the one posted earlier by me is simpler i think ( the one with != )
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|