I want to do the following, but am unsure of how to do it. I have read a number of solutions but they don't seem to fit what I want.
Please keep in mind I only have basic programming experience (some C and Pascal from 20+ years ago), and am trying to re-learn programming. A detailed explanation of some of the more advanced commands would be good.
So, say I have a list of items in a text file as follows:
1-5,foo
6-9,bar
10-12,snafu
13-14,blam
15,bingo
I need to roll randomly on a table three times, each time selecting an element from the table depending on the range it occurs in. Once that item is selected, it cannot be selected again during this process (i.e., each roll must result in a unique element being selected).
i.e., if a roll of four was made, then foo was selected. foo cannot be one of the next two rolls. The next roll results in an 11, that's snafu. snafu cannot be picked from the final roll.
etc etc.
The items picked should then be displayed.
I could do this by having each element on it's own line in the text file, reading the file into an array, find the total number of elements in the array and then randomly select three items from the array, using for loops and temporary arrays to remove the duplicate items of the element selected, but that could be messy.
I'd appreciate both a solution in Java and a solution in Perl but either/or is fine too.
I learn best form practical examples and doing than from reading theory books and websites.
I know I haven't posted any code, but that's because I'm not sure where to start or how to go about this. Any help will be appreciated.