Skip to content

Instantly share code, notes, and snippets.

@cmutel
Last active April 9, 2019 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmutel/da31024c68539cb23582a16b99faf6e3 to your computer and use it in GitHub Desktop.
Save cmutel/da31024c68539cb23582a16b99faf6e3 to your computer and use it in GitHub Desktop.
BONSAI voting on nomenclature for "flow object" possible replacement
orig_data = """BDACFE
DCAFBE
AFDCEB
ADCFBE
CAEBDF
DCABFGHE
AFCED
DCAFBEGH
BGEACDH""".split("\n")
LETTERS = "ABCDEFGH"
def _(x, s, default):
try:
return s.index(x) + 1
except ValueError:
return default + 1
mapping = {x: i + 1 for i, x in enumerate(LETTERS)}
data = [[_(letter, line, len(LETTERS)) for letter in LETTERS] for line in orig_data]
for line in data:
print(str(line)[1:-1])
import numpy as np
for letter in LETTERS:
print(letter, np.average([_(letter, line, len(LETTERS)) for line in orig_data]))
@cmutel
Copy link
Author

cmutel commented Apr 8, 2019

To do instant runoff voting, use https://petertheone.github.io/IRV/

Use this list of candidates:
A
B
C
D
E
F

And these responses printed out by this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment