+ 4

Challenge for Coders.

Write a code to input three numbers Then display which is the second highest number. You cannot use if statement or ternary operator. The program must be coded in Java. Other languages are also welcome, but there must be a Java version attached. This is my first Challenge. Others coming soon. Let's see who wins. This is a question in my school textbook. There it is given: [Hint: Use Math operators.]

24th Jun 2017, 3:50 PM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
16 Answers
24th Jun 2017, 4:21 PM
Limitless
Limitless - avatar
+ 5
I can give highest 😥 [4, 7].max #Ruby
24th Jun 2017, 4:14 PM
Ekansh
+ 5
@Amrit We can't use array.sort in java.util here, right? 😅
24th Jun 2017, 4:17 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
@Kinshuk I did :/ It's a very easy way to do it
24th Jun 2017, 4:22 PM
Limitless
Limitless - avatar
+ 4
@Limitless I did the same, but then thought that the sort function may have some if in its code?
24th Jun 2017, 4:35 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
@Limitless Hmm. You win!
24th Jun 2017, 4:36 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
:/
24th Jun 2017, 4:08 PM
Limitless
Limitless - avatar
+ 3
I made one super fast but it doesn't work in sololearn's IDE.. Not using sort code.sololearn.com/cjdmOxNzJmtz/#java
24th Jun 2017, 4:33 PM
Frederik Bussler
Frederik Bussler - avatar
+ 3
It probably does, but we did not write it and the question didn't say we can't use it ;)
24th Jun 2017, 4:36 PM
Limitless
Limitless - avatar
+ 3
Awesome, thanks, can't wait for your next challange ;)
24th Jun 2017, 4:53 PM
Limitless
Limitless - avatar
+ 3
https://code.sololearn.com/ca3eQnMUQ1t0/?ref=app The same thing, without even using Arrays.sort(arr)...
25th Jun 2017, 2:07 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@Fredrick quickly share
24th Jun 2017, 4:34 PM
Limitless
Limitless - avatar
+ 2
I don't know java but can't we do min and max and take the other?
24th Jun 2017, 5:19 PM
clement
clement - avatar
+ 2
yes That's what we did
24th Jun 2017, 5:19 PM
Limitless
Limitless - avatar
+ 1
we wl use max nd min operations on all the 3 once we get to knw both the left is 2nd highest
24th Jun 2017, 10:31 PM
Vidhi Jain
Vidhi Jain - avatar
25th Jun 2017, 6:57 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar