473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sorting using Max and Min

mia023
89
Is it possible to sort 3 integers in either descending/ascending order using ONLY Math.min and Math.max?
Cannot use the "if", "while", "for", "switch" keywords.
Oct 15 '07 #1
9 5075
dav3
94
Is it possible to sort 3 integers in either descending/ascending order using ONLY Math.min and Math.max?
Cannot use the "if", "while", "for", "switch" keywords.
Can you use a list or an array?
Oct 15 '07 #2
mia023
89
Can you use a list or an array?
No but i have to use the command line arguments.
Oct 16 '07 #3
bravo
43
May be ternary operator can help u....
Oct 16 '07 #4
JosAH
11,448 Expert 8TB
Well the maximum value of x, y and z is max(x, max(y, z)); I sure you can complete
it from here.

kind regards,

Jos
Oct 16 '07 #5
r035198x
13,262 8TB
Well the maximum value of x, y and z is max(x, max(y, z)); I sure you can complete
it from here.

kind regards,

Jos
I expect the problem is determing the middle element.
Oct 16 '07 #6
i think middle element can be determined from x,y,z like this
correct me if i am wrong

min(min(max(x,y),max(x,z)),min(max(x,y),max(y,z)))
Oct 16 '07 #7
JosAH
11,448 Expert 8TB
i think middle element can be determined from x,y,z like this
correct me if i am wrong

min(min(max(x,y),max(x,z)),min(max(x,y),max(y,z)))
Nah way too complicated; spoiler ahead:







































x+y+z-min-max is the middle element.

kind regards,

Jos
Oct 16 '07 #8
r035198x
13,262 8TB
Nah way too complicated; spoiler ahead:







































x+y+z-min-max is the middle element.

kind regards,

Jos
Kindly proceed to the attic ...
Oct 16 '07 #9
JosAH
11,448 Expert 8TB
Kindly proceed to the attic ...
No, I'm afraid of hights; even when I walk on thick socks I get sick.

kind regards,

Jos ;-)
Oct 16 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
10
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to...
7
by: abracadabra | last post by:
I am reading an old book - Programming Pearls 2nd edition recently. It says, "Even though the general C++ program uses 50 times the memory and CPU time of the specialized C program, it requires...
1
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.