Click here to Skip to main content
15,881,715 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionC/C++ algorithm to reorganize and extract the data Pin
feifeihanyu10-Jul-15 4:22
feifeihanyu10-Jul-15 4:22 
SuggestionRe: C/C++ algorithm to reorganize and extract the data Pin
Richard MacCutchan10-Jul-15 4:47
mveRichard MacCutchan10-Jul-15 4:47 
GeneralRe: C/C++ algorithm to reorganize and extract the data Pin
feifeihanyu10-Jul-15 5:53
feifeihanyu10-Jul-15 5:53 
GeneralRe: C/C++ algorithm to reorganize and extract the data Pin
Member 1184955320-Jul-15 3:53
Member 1184955320-Jul-15 3:53 
GeneralRe: C/C++ algorithm to reorganize and extract the data Pin
Richard MacCutchan20-Jul-15 4:40
mveRichard MacCutchan20-Jul-15 4:40 
AnswerRe: C/C++ algorithm to reorganize and extract the data Pin
Supreme Master27-Jul-15 7:44
Supreme Master27-Jul-15 7:44 
GeneralRe: C/C++ algorithm to reorganize and extract the data Pin
Supreme Master27-Jul-15 8:52
Supreme Master27-Jul-15 8:52 
QuestionAlgorithm/Pseudo code help for swapping/comparing values Pin
Member 118111963-Jul-15 1:21
Member 118111963-Jul-15 1:21 
My maths is quite poor and I need some help writing an algorithm/pseudo for a simple cost estimator:

rules
I have three inputs x, y and z. The inputs each have a separate max value that if breached return an error. These max values, X = 20, Y = 15, Z = 30.

Now I need a function that compares the in-putted values and if possible swaps the values to keep them under the constraints. Also,
Z should always contain the smallest value as long as the swapped value still meets the max value constraints.

So for a few examples if the user entered X=15,Y=5,Z=10 the values for y and Z would be swapped to make z the lowest value. With X=5 Y=18 Z=2 X and Y would be swapped with x to fit under max values. With X=10 Y=8 Z=2 nothing would be swapped. X=31 Y=18 Z=10 nothing would be swapped and you would get an error.

I have written this codepen so far:
http://codepen.io/FredHair/pen/gpvoPR?editors=101[^]

It finds the minVal, medVal and maxVal. I just need some help with the next logic steps for swapping the values.

The values themself represent a bounding box, orientating an inputted box that would lead to a cost estimate.

I have already had a go at writing this into a program but I made numerous logical errors.

If anyone can offer any insight into the maths and best way to write this I can then write the code.

Any help is greatly appriceted, I hope I have made myslef clear, feel free to look at codepen and ask any questions.

Regards,

F
AnswerRe: Algorithm/Pseudo code help for swapping/comparing values Pin
Alan Balkany9-Jul-15 11:48
Alan Balkany9-Jul-15 11:48 
AnswerRe: Algorithm/Pseudo code help for swapping/comparing values PinPopular
Patrice T10-Jul-15 21:22
mvePatrice T10-Jul-15 21:22 
Generalto downvoter Pin
Patrice T1-Aug-15 12:47
mvePatrice T1-Aug-15 12:47 
GeneralRe: to downvoter Pin
Richard Deeming3-Aug-15 2:26
mveRichard Deeming3-Aug-15 2:26 
GeneralRe: to downvoter Pin
Patrice T3-Aug-15 10:31
mvePatrice T3-Aug-15 10:31 
QuestionMaybe Original Algorithm Created Pin
Rui__Silva25-Jun-15 5:24
professionalRui__Silva25-Jun-15 5:24 
AnswerRe: Maybe Original Algorithm Created Pin
Patrice T25-Jun-15 8:24
mvePatrice T25-Jun-15 8:24 
GeneralRe: Maybe Original Algorithm Created Pin
Rui__Silva26-Jun-15 0:55
professionalRui__Silva26-Jun-15 0:55 
GeneralRe: Maybe Original Algorithm Created PinPopular
Patrice T26-Jun-15 3:53
mvePatrice T26-Jun-15 3:53 
GeneralRe: Maybe Original Algorithm Created Pin
Richard Deeming1-Jul-15 7:41
mveRichard Deeming1-Jul-15 7:41 
GeneralRe: Maybe Original Algorithm Created Pin
Patrice T1-Jul-15 7:53
mvePatrice T1-Jul-15 7:53 
QuestionOptimal trajectory of area exploration Pin
Viktor Grabarchuk21-Jun-15 21:38
Viktor Grabarchuk21-Jun-15 21:38 
GeneralRe: Optimal trajectory of area exploration Pin
Sascha Lefèvre22-Jun-15 3:30
professionalSascha Lefèvre22-Jun-15 3:30 
GeneralRe: Optimal trajectory of area exploration Pin
Viktor Grabarchuk22-Jun-15 4:04
Viktor Grabarchuk22-Jun-15 4:04 
GeneralRe: Optimal trajectory of area exploration Pin
Eddy Vluggen22-Jun-15 12:18
professionalEddy Vluggen22-Jun-15 12:18 
QuestionWhich algorithm to use for searching on basis of different values Pin
Member 96143523-Jun-15 1:04
Member 96143523-Jun-15 1:04 
AnswerRe: Which algorithm to use for searching on basis of different values Pin
Matt T Heffron3-Jun-15 7:38
professionalMatt T Heffron3-Jun-15 7:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.