Click the green flag to randomize ballots and run the animation. This solution is based on the Boyer–Moore majority vote algorithm: https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm To understand it, you're better off looking at the code in the original project (Solution 1). "An election is held between candidates A, B, C and D. You are given a set of 100 [20 for this demo] completed ballot papers and your job is to work out whether any of the candidates has an overall majority, i.e. won 51 or more votes. If a candidate has done so, you must say who it is. But there’s a catch. You are not allowed to count the ballot papers." All code by me (@kriblo). In the randomization, I added a slight advantage for one candidate, to make a majority more likely for this demo.