Use an array with those five integers, so you can loop it. Then make a function to count distinct values. One of them should have a count of three or more.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
Right. There are more ways to do that, but you should try first.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
In pseudo code:
for each aCount
set to zero
for each aDiceScore
increment aCount[aDiceScore]
for each aCount, index 1..6
if aCount[index] >= 3
score = aCount[index] * index
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
for index := 1 to 6 do
rest here
sorry, was a bit unclear.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
You left one index, which should be K (and you added your code after I replied, messages got mixed up :) )
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
Then perhaps you should add a variable, to check whether it is 3, 4, or 5 (instead of checking for 3+).
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
Instead of:
if aCount[index] >= 3 then
use:
if aCount[index] = myVariable then
myVariable will depend on what the user selects to count, 3, 4 or 5
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
Sorry, typo, use >=
This is what I would do:
for K := 1 to 6 do
if aCount[K] >= myVariable then
begin
iScore := aCount[K] * myVariable;
Break; // get out of the loop, to avoid further processing
end;
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874