Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 11777723

@User 11777723
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Algorithm/Pseudo code help for swapping/comparing values
    U User 11777723

    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

    Algorithms help algorithms question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups