ScratchData LogoScratchData
Back to kriblo_test's profile

Animated: The big ballot brainteaser

KRkriblo_test•Created March 8, 2023
Animated: The big ballot brainteaser
9
7
97 views
View on Scratch

Instructions

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.

Project Details

Project ID815717705
CreatedMarch 8, 2023
Last ModifiedMarch 8, 2023
SharedMarch 8, 2023
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root