You are the electoral strategist for a sudden late entrant in the 2020 US presidental election.

Your task: print out the names of states* your candidate will win, totalling at least 270 electoral college votes.


Each state (and Washington DC) in the US system has an arbitrary number of "electoral college votes". A candidate has to win a majority of the 538 votes available, so at least 270 votes.

The number of votes for each state is:

[['Alabama', 9], ['Alaska', 3], ['Arizona', 11], ['Arkansas', 6], ['California', 55], ['Colorado', 9], ['Connecticut', 7], ['Delaware', 3], ['Florida', 29], ['Georgia', 16], ['Hawaii', 4], ['Idaho', 4], ['Illinois', 20], ['Indiana', 11], ['Iowa', 6], ['Kansas', 6], ['Kentucky', 8], ['Louisiana', 8], ['Maine', 4], ['Maryland', 10], ['Massachusetts', 11], ['Michigan', 16], ['Minnesota', 10], ['Mississippi', 6], ['Missouri', 10], ['Montana', 3], ['Nebraska', 5], ['Nevada', 6], ['New Hampshire', 4], ['New Jersey', 14], ['New Mexico', 5], ['New York', 29], ['North Carolina', 15], ['North Dakota', 3], ['Ohio', 18], ['Oklahoma', 7], ['Oregon', 7], ['Pennsylvania', 20], ['Rhode Island', 4], ['South Carolina', 9], ['South Dakota', 3], ['Tennessee', 11], ['Texas', 38], ['Utah', 6], ['Vermont', 3], ['Virginia', 13], ['Washington', 12], ['Washington DC', 3], ['West Virginia', 5], ['Wisconsin', 10], ['Wyoming', 3]]




A list (or similar) containing just the names of the states in your winning strategy. If a string, there must be separators between state names. States must be capitalised as in the list provided above.

You must not output anything other than valid state names and separators. The number of states in your strategy is up to you.


You may not use any external (or built-in) list of US state names. Standard loopholes are forbidden.

This is code golf. Shortest code in bytes wins, with the electoral college score as a tie-breaker.

Since there is no input, your code can be a program/script/statement rather than a function.

If you are using space as a separator, then you can't include any states with spaces in the name. Or you would have to do something like enclosing each state name in double quotes. (A separator has to be something that could be used to automatically split the string up into the correct elements.)

* For the purpose of this challenge, Washington DC is considered a state.

  • \$\begingroup\$ Related (Put together a Senate majority) \$\endgroup\$ – my pronoun is monicareinstate May 8 at 12:52
  • 2
    \$\begingroup\$ Probably too late now, but I reckon it would've been interesting to have a scoring system that incentivised a high vote tally as well as a low byte count (something like bytes/votes, perhaps). \$\endgroup\$ – Dingus May 8 at 13:10
  • \$\begingroup\$ Yeah, that might have been interesting. Also, printing the abbreviations might have opened up other interesting challenges. \$\endgroup\$ – Steve Bennett May 8 at 13:36
  • 5
    \$\begingroup\$ You may not use any external (or built-in) list of US state names ~> I think this is a borderline non-observable requirement. I suspect that Brotli has most (if not all) the states hard-coded in some internal dictionary. But I'm not supposed to know that, and I'm not even supposed to know that Charcoal uses Brotli under the hood. \$\endgroup\$ – Arnauld May 8 at 16:41
  • 1
    \$\begingroup\$ Related (Output the number of Electoral Votes one state has) \$\endgroup\$ – pppery May 9 at 15:53

10 Answers 10


Charcoal,  52 ... 45  42 bytes (270 votes)

A list of states that optimizes the compression with Brotli.


Try it online!


New York    

Node.js script

The initial list was found with the following Node.js script that shuffles the 30 most efficient states, extracts the shortest leading sub-list with a score greater than or equal to 270, joins it with \r and invokes the Brotli compressor on the resulting string.

It was optimized some more by shuffling the most promising sub-list to find an order offering the best compression.

let states = [ ['Alabama', 9], ['Alaska', 3], ['Arizona', 11], ... ];

states =
  states.map(a => [a[0], a[1], a[1] / a[0].length])
  .sort((a, b) => b[2] - a[2])
  .slice(0, 30);

const zlib = require('zlib');

let bestLen = 1 / 0, bestScore = 1 / 0,
    list, score, str, pack;

while(1) {
  for(let i = states.length - 1; i > 0; i--) {
    let j = Math.floor(Math.random() * (i + 1));
    [ states[i], states[j] ] = [ states[j], states[i] ];

    let n = 1;
    (score = (list = states.slice(0, n)).reduce((p, c) => p + c[1], 0)) < 270;
  ) {}

  str = list.map(s => s[0]).join('\r');
  pack = zlib.brotliCompressSync(Buffer(str));

  if(pack.length < bestLen || (pack.length == bestLen && score <= bestScore)) {
    bestLen = pack.length;
    bestScore = score;
    console.log(bestLen, bestScore, str.split('\r').join('\\r'));
| improve this answer | |
  • 1
    \$\begingroup\$ I found the console.log(bestLen = pack.length, bestScore = score, str.split('\r').join('\\r')) syntax extremely worrying at first glance... \$\endgroup\$ – my pronoun is monicareinstate May 8 at 14:49
  • \$\begingroup\$ @mypronounismonicareinstate Doing important assignments within a console.log?... What's wrong with that?!?... :-p \$\endgroup\$ – Arnauld May 8 at 15:07
  • 2
    \$\begingroup\$ I'm not sure whether that makes the results worse here, but Math.random() - 0.5 is not a transitive nor an anticommutative comparer and is unlikely to produce all permutations with similar probabilities, and according to a statistical analysis on a random blog, it's especially terrible on Chrome, and I assume that extends to V8 and to Node. (random information: I had C++ programs segfault with maximal optimization with a comparer that turned out not to be commutative in a rare edge case) \$\endgroup\$ – my pronoun is monicareinstate May 8 at 15:38
  • \$\begingroup\$ @mypronounismonicareinstate That shouldn't matter much in that case. This method is especially bad for a single pass. But here, each iteration is shuffling the result of the previous one. (Also, we can't try all 30! ~= 2.65*10^32 permutations anyway.) \$\endgroup\$ – Arnauld May 8 at 15:46
  • \$\begingroup\$ @mypronounismonicareinstate Anyway, I've switched to Fisher-Yates as it can only be better, and is also much faster. Thanks! \$\endgroup\$ – Arnauld May 8 at 16:26

05AB1E, 68 66 bytes, 271 votes


Outputs the following 12 states newline-separated, totaling 271 votes:

California,Florida,Georgia,Illinois,Indiana,Michigan,Ohio,Pennsylvania,Texas,Utah,Virginia,New York

Try it online.

If builtins were allowed, we could have used the dictionary for 27 bytes, 270 votes


Outputs the following 13 states space-delimited, totaling exactly 270 votes:

California Texas Florida Pennsylvania Illinois Ohio Michigan Georgia Virginia Washington Tennessee Massachusetts Indiana

Try it online.


õ%î!¯aàáè˜3ÒƵLweh³• # Push compressed string "california florida georgia illinois indiana michigan ohio pennsylvania texas utah virginia"
  #                 # Split it on spaces
   `                # Push them all separated to the stack
    „€¢…Œ           # Push dictionary string "new york" (which are both English words)
         »          # Join all strings on the stack by newlines
          ™         # And title-case each word
                    # (after which it is output implicitly as result)

                    # Push the dictionary string "California Texas Florida Pennsylvania Illinois Ohio Michigan Georgia Virginia Washington Tennessee Massachusetts Indiana"
                    # (after which it is output implicitly as result)

See this 05AB1E tips of mine (sections How to use the dictionary? and How to compress strings not part of the dictionary?) to understand why:

  • .•2Y±e1¸Zí¼³sçj†Ê蔚ʒÕʒ½‘ε-нUeC·ûÝ죅\nõ%î!¯aàáè˜3ÒƵLweh³• is "california florida georgia illinois indiana michigan ohio pennsylvania texas utah virginia";
  • „€¢…Œ is "new york";
  • and ”‡Â†éŠ§›ÕïÁ–ۗї‡¹¢ÇŸÏžÏ is "California Texas Florida Pennsylvania Illinois Ohio Michigan Georgia Virginia Washington Tennessee Massachusetts Indiana".
| improve this answer | |

Charcoal, 59 51 50 41 bytes


Try it online! Link is to verbose version of code. Simply the compressed string for Texas\nVirginia\nIllinois\nMichigan\nGeorgia\nPennsylvania\nFlorida\nWashington\nNew York\nCalifornia\nMassachusetts\nTennessee; total 270 votes.

This solution was found with the help of a Python 3 program that randomly selected voting states and took the length of the resulting string. It then tracked the number of times each state appeared in the strings that were less than a certain cutoff length, initially 60, but gradually reduced to 45 as I optimised the input.

Optimisation consisted both of creating a list of frequently used states and removing infrequently used states from the list thus allowing more shuffles to be performed.

Eventually I got to the point where each shuffle always had the states California, Florida, Georgia, Illinois, Michigan, New York, Pennsylvania and Texas, and four of the six states Arizona, Indiana, Massachusetts, Tennessee, Virginia and Washington. At this point I could generate all 15 combinations of 12 states and just had to shuffle the states around in the hope of getting a short answer. Shuffling script:

import brotli
import itertools
import random
import sys

bigstates = ['California', 'Florida', 'Georgia', 'Illinois', 'Michigan', 'New York', 'Pennsylvania', 'Texas']
smallstates = ['Arizona', 'Indiana', 'Massachusetts', 'Tennessee', 'Virginia', 'Washington']

while True:
 for states in itertools.combinations(smallstates, 4):
  states = bigstates + list(states)
  for j in range(100):
   if len(brotli.compress('\n'.join(states).encode("ascii"))) < 39:

Try it online! The script also found the following shuffles with the same byte count:

Print("Texas\nTennessee\nVirginia\nPennsylvania\nWashington\nCalifornia\nMichigan\nMassachusetts\nNew York\nGeorgia\nFlorida\nIllinois");
Print("Texas\nVirginia\nMichigan\nIllinois\nGeorgia\nPennsylvania\nFlorida\nWashington\nTennessee\nMassachusetts\nNew York\nCalifornia");
Print("Texas\nGeorgia\nTennessee\nVirginia\nIllinois\nPennsylvania\nMichigan\nWashington\nCalifornia\nNew York\nMassachusetts\nFlorida");
Print("Texas\nNew York\nVirginia\nPennsylvania\nWashington\nFlorida\nMassachusetts\nGeorgia\nCalifornia\nTennessee\nMichigan\nIllinois");

Previous 50-byte solution:


Try it online! Link is to verbose version of code. Simply the compressed string for Pennsylvania\nWisconsin\nTexas\nCalifornia\nIllinois\nNew York\nFlorida\nGeorgia\nMichigan\nVirginia\nArizona\nNew Jersey; total 271 votes.

I started off with the best value states, Texas, California, Florida, Ohio, New York, Illinois, Georgia, Michigan, Pennsylvania, Virginia and Arizona, plus Iowa to make up the numbers. I then tried various permutations of states to find out which ones Charcoal compressed best; moving Ohio, Illinois and New York to the end worked best. (There are 12! possibilities so I'm not trying them all.) I then tried switching Arizona and Iowa with Indiana and Utah, taken from @SurculoseSputum's answer; Arizona made no difference but Utah saved a further byte.

Edit: Saved 8 bytes by printing Utah and Ohio literally instead of trying to compress them. Saved a further byte by using New Jersey and Wisconsin instead of Utah and Ohio. (This did mean reordering the states again for optimal compression. Colorado, Indiana, Maryland, Massachusetts, Minnesota, Mississippi and Missouri and also work instead of Wisconsin.)

| improve this answer | |

Python 2, 106 bytes, 271 votes

print"California,Florida,Georgia,Illinois,Indiana,Michigan,New York,Ohio,Pennsylvania,Texas,Utah,Virginia"

Try it online!

Picks the states with the best votes/name length ratio.

Turns out this is the shortest possible combination of states to achieve at least 270, as shown in this DP program.

| improve this answer | |
  • \$\begingroup\$ There's actually a shorter combination with just 11 states: California (55; 55) Texas (38; 93) Florida (29; 122) New York (29; 151) Illinois (20; 171) Pennsylvania (20; 191) Ohio (18; 209) Georgia (16; 225) Michigan (16; 241) North Carolina (15; 256) New Jersey (14; 270) \$\endgroup\$ – ouflak May 8 at 14:35
  • \$\begingroup\$ @outflak while your list has less states, the total length is 4 bytes longer than my current answer. \$\endgroup\$ – Surculose Sputum May 8 at 14:36

Turing Machine Code, 1059 bytes (270 votes)

0 * C r 1
1 * a r 2
2 * l r 3
3 * i r 4
4 * f r 5
5 * o r 6
6 * r r 7
7 * n r 8
8 * i r 9
9 * a r π
π * , r a
a * T r b
b * e r c
c * x r d
d * a r e
e * s r f
f * , r g
g * F r h
h * l r i
i * o r j
j * r r k
k * i r l
l * d r m
m * a r n
n * , r o
o * N r p
p * e r q
q * w r r
r * _ r s
s * Y r t
t * o r u
u * r r v
v * k r w
w * , r x
x * I r y
y * l r z
z * l r A
A * i r B
B * n r C
C * o r D
D * i r E
E * s r F
F * , r G
G * P r H
H * e r I
I * n r J
J * n r K
K * s r L
L * y r M
M * l r N
N * v r O
O * a r P
P * n r Q
Q * i r R
R * a r S
S * , r T
T * O r U
U * h r V
V * i r W
W * o r X
X * , r Y
Y * G r Z
Z * e r `
` * o r ¬
¬ * r r "
" * g r £
£ * i r $
$ * a r %
% * , r ^
^ * M r &
& * i r (
( * c r )
) * h r +
+ * i r {
{ * g r }
} * a r [
[ * n r ]
] * , r -
- * N r =
= * o r :
: * r r '
' * t r @
@ * h r #
# * _ r ~
~ * C r 
> * o r .
. * l r ?
? * i r /
/ * n r |
| * a r \
\ * , r ©
© * N r À
À * e r Á
Á * w r Â
 * _ r Ã
à * J r Ä
Ä * e r Å
Å * r r Æ
Æ * s r Ç
Ç * e r È
È * y r halt

This will print:

California (55; 55)
Texas (38; 93)
Florida (29; 122)
New York (29; 151)
Illinois (20; 171)
Pennsylvania (20; 191)
Ohio (18; 209)
Georgia (16; 225)
Michigan (16; 241)
North Carolina (15; 256)
New Jersey (14; 270)

Or to be more precise: California,Texas,Florida,New York,Illinois,Pennsylvania,Ohio,Georgia,Michigan,North Carolina,New Jersey

Updated to reflect later rule change thanks @Laikoni. No byte size change.

Try it online!

| improve this answer | |
  • \$\begingroup\$ The challenge states "If you are using space as a separator, then you can't include any states with spaces in the name." \$\endgroup\$ – Laikoni May 10 at 10:27
  • \$\begingroup\$ @Laikoni, Thanks for the update. Wouldn't have known otherwise. Wonder if there couldn't be some feature for this site where an OP could 'ping' the answerers if there are significant changes that might affect their answers? \$\endgroup\$ – ouflak May 10 at 12:09
  • \$\begingroup\$ I was not aware that this rule was added to the challenge after you posted your answer. It would have been nice if OP informed the existing answers of this change - the 'ping' you mention is easily achieved by commenting on the answers, especially as there weren't that many. \$\endgroup\$ – Laikoni May 11 at 13:13
  • \$\begingroup\$ Sorry, my bad. (From my point of view, it wasn't "adding a rule", but explicitly stating something that I thought was implicit in the use of the word "separator", but point taken.) \$\endgroup\$ – Steve Bennett May 11 at 13:28

Stax, 75 bytes, 271 votes


Run and debug it

| improve this answer | |

Ruby, 115 bytes

Nor#{s="th Carolina
New "}York

Try it online!

Makes use of the string "th Carolina\nNew "

| improve this answer | |
  • 1
    \$\begingroup\$ @mathjunkie. Thanks, I noticed that after posting. I also noticed that a port of Surculose Sputum's simpler but better researched answer would be shorter than this/ But I'll leave it up as I wanted to share the Carolina/New concept. \$\endgroup\$ – Level River St May 9 at 2:56
  • \$\begingroup\$ I'm glad there are languages that manage to make use of the New/North/South duplications. I tried with JavaScript but didn't save any bytes. \$\endgroup\$ – Steve Bennett May 9 at 7:54

Jelly, 37 bytes


A niladic Link which yields a list of characters using a space as the separator. The states have a total value of 270 (and contain no spaces themselves):

California    55
Texas         38
Florida       29
Pennsylvania  20
Illinois      20
Ohio          18
Georgia       16
Virginia      13
Massachusetts 11
Indiana       11
Arizona       11
Maryland      10
Colorado       9
Alabama        9
           = 270

Try it online!


A compressed string. After taking big hitters containing no spaces I chose states which are earlier alphabetically to keep the result shorter.

| improve this answer | |

Bash, 102 108 bytes (270 electoral votes)

echo \"{{Californ,Georg,Virgin}ia,Florida,Arizona,Indiana,Texas,Ohio,New\ {York,Jersey},Illinois,Michigan}\"

Try it online!

Added 6 bytes to accommodate the modification to the challenge on using a space as a separator. The original answer was:

echo {Californ,Georg,Virgin}ia Florida Arizona Indiana Texas Ohio New\ {York,Jersey} Illinois Michigan
| improve this answer | |
  • \$\begingroup\$ This uses space as a separator, but also includes states with spaces in their names, which isn't valid. (I've updated the rules to clarify this). Sorry if that feels like moving the goalposts - but it doesn't seem right to call something a "separator" if you can't split on it. \$\endgroup\$ – Steve Bennett May 9 at 14:20
  • 1
    \$\begingroup\$ I've accommodated the new rule on spaces at the cost of 6 bytes. \$\endgroup\$ – Mitchell Spector May 9 at 14:49

JavaScript, 114 characters, 270 votes

_=>`California,Texas,Florida,Nor${s='th Carolina,New '}York,Sou${s}Jersey,Illinois,Ohio,Georgia,Michigan,Virginia`

Just a straight port of Level River St's Ruby answer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.