Okay, lets see if I can get my issue across clearly...
Lets say I have 10 departments, each with a different number of people in two columns in a spreadsheet. Lets say the name of the columns are "Department Name" and "Number of People". Now lets say you are given a variable "Total_Number_of_People" (TNP from here on out). I need to find the fewest number of departments that, when added together, come closet to the TNP and return which departments they are and the number of people in each department. I wrote code based on if and do statements nested within each other, and have it working by finding up to four departments which come close to the TNP variable, but there has got to be an easier way, because this way will just keep getting nastier My friend told me to use an array, but didn't have time to explain it. I used arrays back when I was in college in C++. But can't remember how they worked exactly. Anyone have any suggestions? Please save me from the nasty nested if's and do's
Lets say I have 10 departments, each with a different number of people in two columns in a spreadsheet. Lets say the name of the columns are "Department Name" and "Number of People". Now lets say you are given a variable "Total_Number_of_People" (TNP from here on out). I need to find the fewest number of departments that, when added together, come closet to the TNP and return which departments they are and the number of people in each department. I wrote code based on if and do statements nested within each other, and have it working by finding up to four departments which come close to the TNP variable, but there has got to be an easier way, because this way will just keep getting nastier My friend told me to use an array, but didn't have time to explain it. I used arrays back when I was in college in C++. But can't remember how they worked exactly. Anyone have any suggestions? Please save me from the nasty nested if's and do's