Politico's [New Yorkers pick a new mayor after chaotic, historic primary](https://www.politico.com/news/2021/06/22/new-yorkers-new-mayor-primary-495591) begins:

> 
> NEW YORK — Polls have closed in New York City’s first ever ranked-choice election and, while the die has been cast, voters may not know the outcome for weeks.
> 
> 
> [...] Further extending the ballot count is the advent of ranked-choice voting, which allows New Yorkers to select up to five candidates for each position. The system kicks in when no candidate attains 50 percent of votes on the first pass. The board plans to issue preliminary results of ranked ballots on June 29.
> 
> 
> 

According to [this](https://www.politico.com/election-results/2021/new-york-city/mayor/):

> 
> More than a dozen Democrats and two Republicans will vie to replace outgoing Mayor Bill de Blasio (D). The ranked-choice election is expected to take weeks to resolve.
> 
> 
> 

So the number of distinct yet valid ways a person could vote is large. I think that it's the sum of 0-, 1-, 2-, 3-, 4- and 5-from-14 possibilities, but I'm not even sure of that (see below).

I'm curious how New York City will physically and computationally implement ranked-choice vote counting.

**Question:** *Algorithmically* it can be done via several passes of a sorting function over all ranked-choice votes in a table in memory or on a hard drive, but how do they implement this with the various physical forms of votes cast in New York's mayoral election?

Will they resort to all electronic implementation of the algorithm, all physical, or some hybrid method?

---

In Python, assuming (for example) exactly 14 candidates available (in math it's [number of permutations without repetitions](https://en.wikipedia.org/wiki/Permutation#Permutations_without_repetitions))

```
from itertools import permutations
possible = []
for k in [0, 1, 2, 3, 4, 5]:
    uniques = list(permutations('abcdefghijklmn', k))
    possible.append(uniques)
    print(k, len(uniques))
all_possible = sum(possible, [])
print('total: ', len(all_possible))

 k        uniques
 0           1
 1          14
 2         182
 3        2184
 4       24024
 5      240240

total:  266645

```