title: Print the Capitals without the Capitals

text:
# Question
Title: Print the Capitals without the Capitals
Whoa, whoa, whoa ... stop typing your program. No, I don't mean "print `ABC...`." I'm talking the capitals of the United States.

Specifically, print all the city/state combinations given in the following list

* in any order
* with your choice of delimiters (e.g., `Baton Rouge`LA_Indianapolis`IN_...` is acceptable), so long as it's unambiguous which words are cities, which are states, and which are different entries
* without using any of `ABCDEFGHIJKLMNOPQRSTUVWXYZ` in your source code

Output should be to STDOUT or equivalent.

### EDIT - Whoops!

`<edit>`
While typing up the list from memory (thanks to the Animaniacs, as described below), I apparently neglected Washington, DC, which *isn't* a state capital, but *is* in the song, and is sometimes included in "lists of capitals" (like the Mathematica answer below). *I had intended to include that city in this list, but missed it, somehow.* As a result, answers that *don't* have that city won't be penalized, and answers that *do* have that city won't be penalized, either. Essentially, it's up to you whether `Washington, DC` is included in your ouput or not. Sorry about that, folks!
`</edit>`

```
Baton Rouge, LA
Indianapolis, IN
Columbus, OH
Montgomery, AL
Helena, MT
Denver, CO
Boise, ID
Austin, TX
Boston, MA
Albany, NY
Tallahassee, FL
Santa Fe, NM
Nashville, TN
Trenton, NJ
Jefferson, MO
Richmond, VA
Pierre, SD
Harrisburg, PA
Augusta, ME
Providence, RI
Dover, DE
Concord, NH
Montpelier, VT
Hartford, CT
Topeka, KS
Saint Paul, MN
Juneau, AK
Lincoln, NE
Raleigh, NC
Madison, WI
Olympia, WA
Phoenix, AZ
Lansing, MI
Honolulu, HI
Jackson, MS
Springfield, IL
Columbia, SC
Annapolis, MD
Cheyenne, WY
Salt Lake City, UT
Atlanta, GA
Bismarck, ND
Frankfort, KY
Salem, OR
Little Rock, AR
Des Moines, IA
Sacramento, CA
Oklahoma City, OK
Charleston, WV
Carson City, NV

```

<sub>(h/t to Animaniacs for the list of capitals)</sub>

Take a bonus of **-20%** if your submission doesn't explicitly have the numbers `65` through `90` or the number `1` in the code. *Generating* these numbers (e.g., `a=5*13` or `a="123"[0]` or `a=64;a++` or the like) is allowed under this bonus, explicitly having them (e.g., `a=65` or `a="1 23 456"[0]`) is not.

## Leaderboard

```
var QUESTION_ID=60650,OVERRIDE_USER=42963;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+(?:[.]\d+)?)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
# R, ~~96 bytes~~ 98 bytes -20% -\> 78.4

Thanks to @plasticinsect for the bonus!

```
library(maps);data(us.cities);cat(gsub("()( \\w+)$",",\\2",us.cities$n[us.cities$ca==2]),sep="\n")

```

Previous code at 96 bytes:

```
library(maps);data(us.cities);cat(gsub("( \\w+)$",",\\1",us.cities$n[us.cities$ca==2]),sep="\n")

```

From package `maps`, it loads a dataset of US cities. Column `capital` contains a `2` if it is a state capital. The names of the cities are given is column `name` in the form "City StateAbbreviation" (i. e. `Albany NY`), so one need to add an explicit delimiter in between before output. ~~To do so I eventually use the regex `\1` meaning I can't have the bonus I suppose.~~ To avoid using `\1` in the regex I added an empty group so that I can use `\2`.

Usage:

```
> library(maps);data(us.cities);cat(gsub("()( \\w+)$",",\\2",us.cities$n[us.cities$ca>1]),sep="\n")
Albany, NY
Annapolis, MD
Atlanta, GA
Augusta, ME
Austin, TX
Baton Rouge, LA
Bismarck, ND
Boise, ID
Boston, MA
Carson City, NV
Charleston, WV
Cheyenne, WY
Columbia, SC
Columbus, OH
Concord, NH
Denver, CO
Des Moines, IA
Dover, DE
Frankfort, KY
Harrisburg, PA
Hartford, CT
Helena, MT
Honolulu, HI
Indianapolis, IN
Jackson, MS
Jefferson City, MO
Juneau, AK
Lansing, MI
Lincoln, NE
Little Rock, AR
Madison, WI
Montgomery, AL
Montpelier, VT
Nashville, TN
Oklahoma City, OK
Olympia, WA
Phoenix, AZ
Pierre, SD
Providence, RI
Raleigh, NC
Richmond, VA
Sacramento, CA
Saint Paul, MN
Salem, OR
Salt Lake City, UT
Santa Fe, NM
Springfield, IL
Tallahassee, FL
Topeka, KS
Trenton, NJ

```
> 8 votes

# Answer
# Mathematica, ~~168~~ ~~153~~ 149 bytes - 20% = 119.2 bytes

```
u="\.55nited\.53tates";\.41dministrative\.44ivision\.44ata[{#,u}&/@\.43ountry\.44ata[u,"\.52egions"],{"\.43apital\.4eame","\.53tate\.41bbreviation"}]

```

Obligatory, but I did not know that any character can be replaced by `\.xx` or `\:xxxx` with the appropriate hex code.

Edit: Cut of 4 more characters by replacing `Thread` with a pure function.

Output:

```
{{Montgomery,AL},{Juneau,AK},{Phoenix,AZ},{Little Rock,AR},{Sacramento,CA},{Denver,CO},{Hartford,CT},{Dover,DE},{Washington,DC},{Tallahassee,FL},{Atlanta,GA},{Honolulu,HI},{Boise,ID},{Springfield,IL},{Indianapolis,IN},{Des Moines,IA},{Topeka,KS},{Frankfort,KY},{Baton Rouge,LA},{Augusta,ME},{Annapolis,MD},{Boston,MA},{Lansing,MI},{Saint Paul,MN},{Jackson,MS},{Jefferson City,MO},{Helena,MT},{Lincoln,NE},{Carson City,NV},{Concord,NH},{Trenton,NJ},{Santa Fe,NM},{Albany,NY},{Raleigh,NC},{Bismarck,ND},{Columbus,OH},{Oklahoma City,OK},{Salem,OR},{Harrisburg,PA},{Providence,RI},{Columbia,SC},{Pierre,SD},{Nashville,TN},{Austin,TX},{Salt Lake City,UT},{Montpelier,VT},{Richmond,VA},{Olympia,WA},{Charleston,WV},{Madison,WI},{Cheyenne,WY}}

```
> 27 votes

# Answer
# CJam, 312 bytes

```
".ýç9.5i-jæ¤þ¸«Ã«cj|ù;ÎüÄ`Ñ¯Äÿçsøi4ÔÚ0;¾o'ÈàÚãÕ»®¼v{Ðù·*ñfiö\^é]ù¬ðö¸qÚpÿ©a$ÿÆhk¥½éØ×ïÕ{ñ9ÁÛ%Ðø¦ð·âßxâj   Öë¬¯,Ð+?Û¡!ù%Âí©Úfx`¤|}¼>qñµÉÎ4Óæj-wöÄÆ 4,üÖáÌxsÍ·üãýÛêmÁj±æ0?³¢¶§%Û57Ëmc.~`b=´á¥ÉpË,ôb¶ÌsÁì¾*§òÿ_Ö©;<tíèz6ljç¸b§èäø>`ÍÚ×¤ÒòÔ§~hÝ®Ú8¼}8Ì7rÿé×ÔÎîæ¡©)Ô@"'[fm256,f=)b27b'`f+'`/{_2>'q/32af.^' *o2<eup}/

```

The code is **390 bytes** long and qualifies for the **20% bonus**.

Note that the code is riddled with unprintable characters. Try it online in the CJam interpreter.

### Idea

We have to encode the output somehow without using uppercase letters or the numbers 1 and 65 to 90 anywhere in the code.

We start by rewriting the desired output as

```
akjuneau`paharrisburg`txaustin`maboston`wvcharleston`azphoenix`kyfrankfort`msjackson`mdannapolis`vtmontpelier`ndbismarck`hihonolulu`meaugusta`nvcarsonqcity`sccolumbia`ohcolumbus`wycheyenne`casacramento`arlittleqrock`nmsantaqfe`mnsaintqpaul`idboise`tnnashville`codenver`nhconcord`almontgomery`inindianapolis`riprovidence`utsaltqlakeqcity`ilspringfield`ncraleigh`labatonqrouge`sdpierre`dedover`orsalem`waolympia`kstopeka`varichmond`cthartford`nyalbany`milansing`njtrenton`mthelena`iadesqmoines`gaatlanta`wimadison`nelincoln`fltallahassee`okoklahomaqcity`mojefferson

```

By subtracting the character ``` from all characters of that string, we obtain an array containing integers from 0 to 26. We can convert this array from base 27 to base 229, yielding an array of integers from 0 to 228.

If we add 91 to each base-229 digit and take the results modulo 256, we map the range **\[0, …, 164\]** to **\[91, … 255\]**, and the range **\[165, …, 228\]** to **\[0, …, 63\]**. This leaves the characters with code points from **64** (`@`) to **90** (`Z`) unused.

The string to encode is not in the same order as the sample output in the question. I tried several permutation until I found one that contains no null bytes, linefeeds, carriage returns or non-breaking spaces (problematic with the online interpreter), and no double quotes (require escaping).

### Code

```
"…@"   e# Push a string of 342 ISO-8859-1 characters.
'[fm   e# Subtract the char '[' (code point 91) from each char of the string.
256,f= e# Compute the remainder of the differences divided by 256.
)      e# Pop the last integer from the array ('@' -> 27 -> 229).
b27b   e# Convert the remaining array from base 229 to base 27.
'`f+   e# Add the character '`' to the resulting digits.
       e# This pushes the string from the "Idea" section.
'`/    e# Split the result at backticks.
{      e# For each resulting chunk C:
  _2>  e#   Copy C and remove its first to characters.
  'q/  e#   Split at occurrences of 'q'.
  32a  e#   Push [32].
  f.^  e#   Mapped, vectorized XOR; XOR the first character of each chunk
       e#   with 32. This changes its case.
  ' *  e#   Join the resulting chunks, separating by spaces.
  o    e#   Print.
  2<   e#   Reduce the original C to its first two characters.
  eu   e#   Convert to uppercase.
  p    e#   Print, enclosed in double quotes, and followed by a linefeed.
}/     e#

```
> 8 votes

# Answer
# javascript, ~~727~~ 687 bytes - 20% = 549.6

```
alert('baton rouge;indianapolis;columbus;montgomery;helena;denver;boise;austin;boston;albany;tallahassee;santa fe;nashville;trenton;jefferson;richmond;pierre;harrisburg;augusta;providence;dover;concord;montpelier;hartford;topeka;saint paul;juneau;lincoln;raleigh;madison;olympia;phoenix;lansing;honolulu;jackson;springfield;columbia;annapolis;cheyenne;salt lake city;atlanta;bismarck;frankfort;salem;little rock;des moines;sacramento;oklahoma city;charleston;carson city'.split`;`.map((a,i)=>a.split` `.map(b=>b[0][u='to\x55pper\x43ase']()+b.slice(-~0)).join` `+0+'lainohalmtcoidtxmanyflnmtnnjmovasdpameridenhvtctksmnaknencwiwaazmihimsilscmdwyutgandkyorariacaokwvnv'[u]().substr(i*2,2)))

```

javascript is particularly tough as well, considering their long function names and camelcase. splitting out the states saved a ton on delimiters, and made it easier to work with all around.

@mbomb007 nothing in the post capitalized for a reason ;)
> 7 votes

# Answer
# Perl, 605 bytes - 20% = 484

```
$_="baton rouge,laindianapolis,incolumbus,ohmontgomery,alhelena,mtdenver,coboise,idaustin,txboston,maalbany,nytallahassee,flsanta fe,nmnashville,tntrenton,njjefferson,morichmond,vapierre,sdharrisburg,paaugusta,meprovidence,ridover,deconcord,nhmontpelier,vthartford,cttopeka,kssaint paul,mnjuneau,aklincoln,neraleigh,ncmadison,wiolympia,waphoenix,azlansing,mihonolulu,hijackson,msspringfield,ilcolumbia,scannapolis,mdcheyenne,wysalt lake city,utatlanta,gabismarck,ndfrankfort,kysalem,orlittle rock,ardes moines,iasacramento,caoklahoma city,okcharleston,wvcarson city,nv";s/,../uc"$&;"/eg;s/\b./\u$&/g;print

```

My first version was invalid because it used \U to convert to uppercase. This one uses \u on each letter of the state abbreviation. I also had to add a dummy capture group to avoid using $1.

**Edit:** I was able to shave off 8 bytes by using uc() with the e flag. (Thank you Dom Hastings.)
> 7 votes

# Answer
# C, ~~703~~ 700 bytes - 20% = 560 bytes

```
main(){int c=!0;char*p="@baton@rouge[la*indianapolis[in*columbus[oh*montgomery[al*helena[mt*denver[co*boise[id*austin[tx*boston[ma*albany[ny*tallahassee[fl*santa@fe[nm*nashville[tn*trenton[nj*jefferson[mo*richmond[va*pierre[sd*harrisburg[pa*augusta[me*providence[ri*dover[de*concord[nh*montpelier[vt*hartford[ct*topeka[ks*saint@paul[mn*juneau[ak*lincoln[ne*raleigh[nc*madison[wi*olympia[wa*phoenix[az*lansing[mi*honolulu[hi*jackson[ms*springfield[il*columbia[sc*annapolis[md*cheyenne[wy*salt@lake@city[ut*atlanta[ga*bismarck[nd*frankfort[ky*salem[or*little@rock[ar*des@moines[ia*sacramento[ca*oklahoma@city[ok*charleston[wv*carson@city[nv*";while(*++p)c+=*p<97?2+*p/91:0,printf("%c",c?--c,*p-32:*p);}

```

I changed the loop a bit to make it compile with non-C99 compilers. Online version
> 5 votes

# Answer
# Python 3, ~~1416~~ ~~793~~ ~~785~~ ~~779~~ ~~771~~ ~~755~~ 734 characters - 20% = 587.2

No algorithmic cleverness here, I just took the required output, sorted it (this lets zlib do a better job), compressed it (using `zopfli --deflate`), base64-encoded the result, and then changed the encoding around to avoid capital letters.

```
import zlib,base64;print(zlib.decompress(base64.b64decode('>_"@sq*w%>yf^+?!|#-#rii*hezbdf9()#_&m&",s;bb74@n7_93,t>d09rek;+~<l1":+>sr!m~qgv?0[,)z;?>$|p5.i)hegtak<&:db9hg9(xat3yp%x_(j}m]<j7^d?-2$g]5.l:-:g/{da?ow+ykpu}..8g)9"b+h7/[p]ex%x#rp!7u0w3*66|/%:{idbsh|$v/&0^9l!?v8hn-m8%"l^7wx]%_k>h1k(xh~1))h/<x0wdr7")7024.f6~qb;<;$5{tby$>_nid-d!x+,pl0zt[yj5bv"/<+^,$ti>}]3q!gd6>:h/sw}<#x>-lj5#h@w:i01d?m^ks2|,v"^coy^p.l{l{6jxbs,a??m14/h0%/m3j-q_zm@;uu[rgx<(4{{s,en/":1oc|!]fvpsjt$}9z?b&#^;58%@m78i8wf<*u",mizg7;3.3*l7o{0,._oyz0&y5d#afpgc38_-ww_7jx;xd;,:ooaj<u;i5~y]^%u]{.},@_|h[,8^>zt54ohq@y,aw2|20s)$k"|dso*<ra](%%jm<+&upl%[)y/?+{[|<jr8!w=='.translate({ord(x):y+60+5 for x,y in zip('!"#$%&()*,-.:;<>?@[]^_{|}~',range(26))})),-9).decode('u8'))

```

Un-golfed:

```
import zlib, base64

DATA = '>_"@sq*w%>yf^+?!|#-#rii*hezbdf9()#_&m&",s;bb74@n7_93,t>d09rek;+~<l1":+>sr!m~qgv?0[,)z;?>$|p5.i)hegtak<&:db9hg9(xat3yp%x_(j}m]<j7^d?-2$g]5.l:-:g/{da?ow+ykpu}..8g)9"b+h7/[p]ex%x#rp!7u0w3*66|/%:{idbsh|$v/&0^9l!?v8hn-m8%"l^7wx]%_k>h1k(xh~1))h/<x0wdr7")7024.f6~qb;<;$5{tby$>_nid-d!x+,pl0zt[yj5bv"/<+^,$ti>}]3q!gd6>:h/sw}<#x>-lj5#h@w:i01d?m^ks2|,v"^coy^p.l{l{6jxbs,a??m14/h0%/m3j-q_zm@;uu[rgx<(4{{s,en/":1oc|!]fvpsjt$}9z?b&#^;58%@m78i8wf<*u",mizg7;3.3*l7o{0,._oyz0&y5d#afpgc38_-ww_7jx;xd;,:ooaj<u;i5~y]^%u]{.},@_|h[,8^>zt54ohq@y,aw2|20s)$k"|dso*<ra](%%jm<+&upl%[)y/?+{[|<jr8!w=='

TR = { ord(x) : y+60+5
       for x,y in zip('!"#$%&()*,-.:;<>?@[]^_{|}~', range(26)) }

print(zlib.decompress(base64.b64decode(DATA.translate(TR)),
                      -9)
      .decode('utf-8'))

```

There is probably more to be squeezed out of this, especially if you can express the argument to `translate()` more compactly. Note that the punctuation in there is carefully chosen to avoid base64's own punctuation (+/=) and anything that would need backwhacking in a string literal.

Fun fact: the bz2 and lzma modules both do *worse* on this input than zlib:

```
>>> z = base64.b64decode('>_"@sq*w%>yf^+?!|#-#rii*hezbdf9()#_&m&",s;bb74@n7_93,t>d09rek;+~<l1":+>sr!m~qgv?0[,)z;?>$|p5.i)hegtak<&:db9hg9(xat3yp%x_(j}m]<j7^d?-2$g]5.l:-:g/{da?ow+ykpu}..8g)9"b+h7/[p]ex%x#rp!7u0w3*66|/%:{idbsh|$v/&0^9l!?v8hn-m8%"l^7wx]%_k>h1k(xh~1))h/<x0wdr7")7024.f6~qb;<;$5{tby$>_nid-d!x+,pl0zt[yj5bv"/<+^,$ti>}]3q!gd6>:h/sw}<#x>-lj5#h@w:i01d?m^ks2|,v"^coy^p.l{l{6jxbs,a??m14/h0%/m3j-q_zm@;uu[rgx<(4{{s,en/":1oc|!]fvpsjt$}9z?b&#^;58%@m78i8wf<*u",mizg7;3.3*l7o{0,._oyz0&y5d#afpgc38_-ww_7jx;xd;,:ooaj<u;i5~y]^%u]{.},@_|h[,8^>zt54ohq@y,aw2|20s)$k"|dso*<ra](%%jm<+&upl%[)y/?+{[|<jr8!w=='.translate({ord(x):ord(y)-32 for x,y in zip('!"#$%&()*,-.:;<>?@[]^_{|}~','abcdefghijklmnopqrstuvwxyz')}))
>>> u = zlib.decompress(x,-9)
>>> len(u)
663
>>> len(z)
427
>>> len(zlib.compress(z))
437
>>> len(bz2.compress(z))
456
>>> len(lzma.compress(z))
620

```
> 5 votes

# Answer
# javascript (es6) 516 (645-20%) ~~532 (664-20%)~~

test running the snippet below in any recent browser: the only es6 feature used is `template strings`

```
alert(`
labaton rouge
inindianapolis
ohcolumbus
almontgomery
mthelena
codenver
idboise
txaustin
maboston
nyalbany
fltallahassee
nmsanta fe
tnnashville
njtrenton
mojefferson
varichmond
sdpierre
paharrisburg
meaugusta
riprovidence
dedover
nhconcord
vtmontpelier
cthartford
kstopeka
mnsaint paul
akjuneau
nelincoln
ncraleigh
wimadison
waolympia
azphoenix
milansing
hihonolulu
msjackson
ilspringfield
sccolumbia
mdannapolis
wycheyenne
utsalt lake city
gaatlanta
ndbismarck
kyfrankfort
orsalem
arlittle rock
iades moines
casacramento
okoklahoma city
wvcharleston
nvcarson city
`.replace(/(\n..)(.)| ./g,(w,x,y)=>(y?x+','+y:w)['to\x55pper\x43ase']()))
```
> 5 votes

# Answer
# Funciton, 5045 − 20% = 4036 bytes

This code contains only one number, and it’s not in the range 65 through 90. Nor is it the number 1. In fact, this number is 4187 decimal digits, which cleanly factorizes into primes 79×53.

As always, get nicer rendering by executing `$('pre').css('line-height',1);` in your browser console.

```
╔═══════════════════════════════════════════════════════════════════════════════╗
║7136715096855386138244201921379984522081157959387689102965666099527710666770872║
║8632405046019650473694855863386057142772501332293800147289916078651647760772443║
║8725652766505885348060772769789231580343563435533130895917300237406562638030980║
║3711194146648873765244744781953334585902685570475123886704870369061449702689564║
║3595572359214492754563209811697465519112054922140302657793458997381684588970868║
║7793823212145990790477442216616349142872430200820970858787998435483524660584416║
║6164882066597488329789212167115912389108306700132767580336075847661452995278441║
║4608506136620095732142590833871485553260077395557115141102093496100483811080395║
║6552804273104384398276311006450509670233242612250087379855689038722276735360412║
║6878753848057526563710344191563893599886868947829201220173418232286377514939888║
║5826479634935379423693839085984565815131964110239432620200938530722481854602826║
║9037704900171802579729347376622932167603510862768435434759967894116610786905139║
║7412487476129828359043674372610945304257752777678880166233522176263310236004692║
║0559345181857154078616512980811741354072155133642234106705715867670036797456411║
║3264775046807948785891163930492821367841190494057926544207551600789781134233199║
║4931373746463823081063091455500394879663289567724955802959562627212816895887920║
║2489552640528826478935177736926106383314641517898028085103843993947923512080284║
║1297634633899484758145253947029431905171166312060063580822580997396575916969283║
║8159188436765390151074141915725490631912068692580040188837785831216953037087556║
║0321645257600479747768084542577912902995339088536912361110657756023624089620615║
║5158613866208649015722071421838484405731207470388752536584022013701916919845375║
║3209922919010373613440766178725948038885270419846274466164969481905438092706837║
║6125745847739006120558864887675350117798119205719776692338137137532239709753293║
║8995102505657504327982204450387974737246780507128822708181598416111438056330283║
║4785530759635414792062372089201435348108257958259667891277855066169836153935818║
║4849044313927545256942990267263122642672090579649898429311837755460330426123991║
║0865666851722460685754104973378688314066186075716326618952555696686125861179585╟
║7767008528632788251800639156553539356488180142086268151130154661765322967918167║
║6359863162328432204277806522752416226370770476079674225817370337594249020946663║
║1822184578010876426310754786368155838502939742370374540683825491575130213369657║
║2120804668997619419445916101731942338784683470192383635854329364775377151471990║
║2655205750667024595911951526939478313795716952326483704217123605616832952264503║
║8356212760984291960912048067411637475389334580447270650407546381067041317195274║
║3658815060537830411410963930585836537141345277217896786840243174681916988181583║
║8390084258839955570465021603546831767108002881554379542200508579678822598563892║
║8621176190864640015677903257299296220003472794175916462345690686103548377723578║
║6760505049046712538526435515066511975271300115330547105472335029933058732991785║
║5589232894601143279598099962031945524489480851133384138840761826907713777131329║
║9653475711559777326388996740771947433446060772704682592783253818915955015393899║
║8513366910314301930539317844646403762279062435716757707854074235922915355490960║
║9007713445763282900095169953058848056683723033266818136479787173846475991012202║
║9462375527766882809250645176534521094942659081258046722219759280486004661723805║
║6786432900677055552677470564184679327084173152258835307889916896828977570843423║
║3265510347632679682249919679555731735198061941806081777484490821424077128775482║
║4866960679621740266038712499696089430677992126743925060145440886995190894304525║
║3469457565680576996559817327023534136403178656947913819462072799063875416015296║
║0646268276069839972076911667210841845209380552353634062961962574981823297845248║
║7817510295701815725710777747052257272070773995280590130309991890195320939352205║
║3629070121725848802522009518874134452415909082137665653417182020188245139223466║
║1804690429428088774753298257855093982064922470661344462996583642233273038068537║
║5899655675409028134860922908216970845189239846431322757349357911553610461726138║
║9065104191927373357937390905721074233359257891159853454407258925428691711525208║
║0898360915775189300266760522953739009955921695946386500512104598494398514200642║
╚═══════════════════════════════════════════════════════════════════════════════╝

```

Edit: Kiri-ban! This answer is codegolf.SE post #61000!
> 5 votes

# Answer
## x86 machine code, 764 bytes

612 if bonus awarded

Totally self-contained program. Only relies upon (a) Bios int 0x10 being available to print each char and (b) DS, ES, SP and SS being initialized before program is called, DOS does this.(and DOS-Box too) Otherwise, the code relies on nothing. The absolute minimum without any dependencies at all except for the BIOS rom, would be about 2 floppy disk sectors @512 bytes each.

It doesn't seem to exploit any of the standard loop-holes, though while some bytes of the program are 01, these are not numbers in the source. However, since I'd like to submit the binary code as my solution, I imagine that would disallow the 01 bytes.?

Hex-editor view of binary:

```
68 98 01 E8 1D 00 CD 20 B3 62 FE CB 88 DF 80 C7 19 38 D8 72 0D 38 F8 77 09 30 DB FE C3 C0 E3 05 -   h˜.è..Í ³bþËˆß€Ç.8Ør.8øw.0ÛþÃÀã.
28 D8 C3 55 89 E5 81 C5 04 00 8B 76 00 89 F7 AC A8 FF 74 3E 80 3E 96 01 00 75 0A E8 CA FF AA A2 -   (ØÃU‰å.Å..‹v.‰÷¬¨ÿt>€>–..u.èÊÿª¢
96 01 E9 EA FF 3C 2C 75 18 AA AC E8 BA FF AA AC E8 B5 FF AA AC AA AC E8 AE FF AA A2 96 01 E9 CE -   –.éêÿ<,u.ª¬èºÿª¬èµÿª¬ª¬è®ÿª¢–.éÎ
FF 80 3E 96 01 20 75 03 E8 9D FF AA A2 96 01 E9 BD FF 8B 76 00 AC A8 FF 74 1A 3C 2D 75 0F B0 0D -   ÿ€>–. u.è.ÿª¢–.é½ÿ‹v.¬¨ÿt.<-u.°.
B4 0E CD 10 B0 0A B4 0E CD 10 E9 E8 FF B4 0E CD 10 E9 E1 FF 5D C3 00 00 62 61 74 6F 6E 72 6F 75 -   ´.Í.°.´.Í.éèÿ´.Í.éáÿ]Ã..batonrou
67 65 2C 6C 61 2D 69 6E 64 69 61 6E 61 70 6F 6C 69 73 2C 69 6E 2D 63 6F 6C 75 6D 62 75 73 2C 6F -   ge,la-indianapolis,in-columbus,o
68 2D 6D 6F 6E 74 67 6F 6D 65 72 79 2C 61 6C 2D 68 65 6C 65 6E 61 2C 6D 74 2D 64 65 6E 76 65 72 -   h-montgomery,al-helena,mt-denver
2C 63 6F 2D 62 6F 69 73 65 2C 69 64 2D 61 75 73 74 69 6E 2C 74 78 2D 62 6F 73 74 6F 6E 2C 6D 61 -   ,co-boise,id-austin,tx-boston,ma
2D 61 6C 62 61 6E 79 2C 6E 79 2D 74 61 6C 6C 61 68 61 73 73 65 65 2C 66 6C 2D 73 61 6E 74 61 66 -   -albany,ny-tallahassee,fl-santaf
65 2C 6E 6D 2D 6E 61 73 68 76 69 6C 6C 65 2C 74 6E 2D 74 72 65 6E 74 6F 6E 2C 6E 6A 2D 6A 65 66 -   e,nm-nashville,tn-trenton,nj-jef
66 65 72 73 6F 6E 2C 6D 6F 2D 72 69 63 68 6D 6F 6E 64 2C 76 61 2D 70 69 65 72 72 65 2C 73 64 2D -   ferson,mo-richmond,va-pierre,sd-
68 61 72 72 69 73 62 75 72 67 2C 70 61 2D 61 75 67 75 73 74 61 2C 6D 65 2D 70 72 6F 76 69 64 65 -   harrisburg,pa-augusta,me-provide
6E 63 65 2C 72 69 2D 64 6F 76 65 72 2C 64 65 2D 63 6F 6E 63 6F 72 64 2C 6E 68 2D 6D 6F 6E 74 70 -   nce,ri-dover,de-concord,nh-montp
65 6C 69 65 72 2C 76 74 2D 68 61 72 74 66 6F 72 64 2C 63 74 2D 74 6F 70 65 6B 61 2C 6B 73 2D 73 -   elier,vt-hartford,ct-topeka,ks-s
61 69 6E 74 20 70 61 75 6C 2C 6D 6E 2D 6A 75 6E 65 61 75 2C 61 6B 2D 6C 69 6E 63 6F 6C 6E 2C 6E -   aint paul,mn-juneau,ak-lincoln,n
65 2D 72 61 6C 65 69 67 68 2C 6E 63 2D 6D 61 64 69 73 6F 6E 2C 77 69 2D 6F 6C 79 6D 70 69 61 2C -   e-raleigh,nc-madison,wi-olympia,
77 61 2D 70 68 6F 65 6E 69 78 2C 61 7A 2D 6C 61 6E 73 69 6E 67 2C 6D 69 2D 68 6F 6E 6F 6C 75 6C -   wa-phoenix,az-lansing,mi-honolul
75 2C 68 69 2D 6A 61 63 6B 73 6F 6E 2C 6D 73 2D 73 70 72 69 6E 67 66 69 65 6C 64 2C 69 6C 2D 63 -   u,hi-jackson,ms-springfield,il-c
6F 6C 75 6D 62 69 61 2C 73 63 2D 61 6E 6E 61 70 6F 6C 69 73 2C 6D 64 2D 63 68 65 79 65 6E 6E 65 -   olumbia,sc-annapolis,md-cheyenne
2C 77 79 2D 73 61 6C 74 20 6C 61 6B 65 20 63 69 74 79 2C 75 74 2D 61 74 6C 61 6E 74 61 2C 67 61 -   ,wy-salt lake city,ut-atlanta,ga
2D 62 69 73 6D 61 72 63 6B 2C 6E 64 2D 66 72 61 6E 6B 66 6F 72 74 2C 6B 79 2D 73 61 6C 65 6D 2C -   -bismarck,nd-frankfort,ky-salem,
6F 72 2D 6C 69 74 74 6C 65 20 72 6F 63 6B 2C 61 72 2D 64 65 73 20 6D 6F 69 6E 65 73 2C 69 61 2D -   or-little rock,ar-des moines,ia-
73 61 63 72 61 6D 65 6E 74 6F 2C 63 61 2D 6F 6B 6C 61 68 6F 6D 61 20 63 69 74 79 2C 6F 6B 2D 63 -   sacramento,ca-oklahoma city,ok-c
68 61 72 6C 65 73 74 6F 6E 2C 77 76 2D 63 61 72 73 6F 6E 20 63 69 74 79 2C 6E 76 00             -   harleston,wv-carson city,nv.

```

'Un-golfed' version (source - 3126 bytes)

```
[section .text]
[bits 16]
[org 0x100]
entry_point:
    push    word capital_list
    call    output_string
    int 0x20

; input:
;       al = char
; outpt:
;       if al if an alpha char, ensures it is in range [capital-a .. capital-z]
toupper:
    mov     bl, 98
    dec     bl              ; bl = 'a'
    mov     bh, bl
    add     bh, 25          ; bh = 'z'
    cmp     al, bl          ;'a'
    jb      .toupperdone
    cmp     al, bh
    ja      .toupperdone
    xor     bl, bl
    inc     bl
    shl     bl, 5           ; bl = 32
    sub     al, bl          ;capital'a' - 'a' (32)
.toupperdone:
    ret

;void outputstring(char *str)
outputstring:
    push    bp
    mov     bp, sp
    add     bp, 4

    mov     si, [bp + 0]        ; si --> string
    mov     di, si

; I run over the text in two passes - because I'm too tired right now to make it
;   a tighter, more efficient loop. Perhaps after some sleep.
; In the first pass, I just convert the appropriate chars to upper-case
.get_char_pass_1:
    lodsb
    test    al, 0xff
    jz      .pass_1_done
    cmp     [last_char], byte 0
    jne     .not_first_char
    call    toupper
    stosb
    mov     [last_char], al
    jmp     .get_char_pass_1
.not_first_char:
.check_if_sep:
    cmp     al, ','             ; if this char is a comma, the next 2 need to be uppercase
    jne     .not_seperator
    stosb                       ; spit out the comma, unchanged
    lodsb
    call    toupper
    stosb
    lodsb
    call    toupper
    stosb
.gobble_delim:
    lodsb                       ; take care of the '-' delimiter
    stosb
.capitalize_first_letter_of_city:
    lodsb                       ; the following char is the first char of the city, capitalize it
    call    toupper
    stosb
    mov     [last_char], al
    jmp     .get_char_pass_1    ; go back for more
.not_seperator:
    cmp     [last_char], byte ' '
    jne     .output_this_char
    call    toupper
.output_this_char:
    stosb
    mov     [last_char], al
    jmp     .get_char_pass_1
.pass_1_done:

; In the second pass, I print the characters, except for the delimiters, which are skipped and
;   instead print a CRLF pair so that each city/state pair begins on a new line.
;
pass_2:
    mov     si, [bp+0]          ; point to string again
.pass_2_load_char:
    lodsb
    test    al, 0xff
    jz      .pass_2_done
    cmp     al, '-'             ; current char is a delimiter, dont print it - instead,
                                ;  print a carriage-return/line-feed pair
    jne     .not_delim_2
    mov     al, 0xd             ; LF
    mov     ah, 0xe
    int     0x10
    mov     al, 0xa             ; CR
    mov     ah, 0xe
    int     0x10
    jmp     .pass_2_load_char
.not_delim_2:
    mov     ah, 0xe
    int     0x10
    jmp     .pass_2_load_char
.pass_2_done:
    pop     bp
    ret
last_char   db  0

[section .data]
capital_list    db  'batonrouge,la-indianapolis,in-columbus,oh-montgomery,al-helena,mt-denver,co-boise,id-'
                db  'austin,tx-boston,ma-albany,ny-tallahassee,fl-santafe,nm-nashville,tn-trenton,nj-'
                db  'jefferson,mo-richmond,va-pierre,sd-harrisburg,pa-augusta,me-providence,ri-dover,de-'
                db  'concord,nh-montpelier,vt-hartford,ct-topeka,ks-saint paul,mn-juneau,ak-lincoln,ne-'
                db  'raleigh,nc-madison,wi-olympia,wa-phoenix,az-lansing,mi-honolulu,hi-jackson,ms-'
                db  'springfield,il-columbia,sc-annapolis,md-cheyenne,wy-salt lake city,ut-atlanta,ga-'
                db  'bismarck,nd-frankfort,ky-salem,or-little rock,ar-des moines,ia-sacramento,ca-'
                db  'oklahoma city,ok-charleston,wv-carson city,nv',0

```

Output:

```
Baton Rouge,LA
Indianapolis,IN
Columbus,OH
Montgomery,AL
Helena,MT
Denver,CO
Boise,ID
Austin,TX
Boston,MA
Albany,NY
Tallahassee,FL
Santa Fe,NM
Nashville,TN
Trenton,NJ
Jefferson,MO
Richmond,VA
Pierre,SD
Harrisburg,PA
Augusta,ME
Providence,RI
Dover,DE
Concord,NH
Montpelier,VT
Hartford,CT
Topeka,KS
Saint Paul,MN
Juneau,AK
Lincoln,NE
Raleigh,NC
Madison,WI
Olympia,WA
Phoenix,AZ
Lansing,MI
Honolulu,HI
Jackson,MS
Springfield,IL
Columbia,SC
Annapolis,MD
Cheyenne,WY
Salt Lake City,UT
Atlanta,GA
Bismarck,ND
Frankfort,KY
Salem,OR
Little Rock,AR
Des Moines,IA
Sacramento,CA
Oklahoma City,OK
Charleston,WV
Carson City,NV

```
> 5 votes

# Answer
# Pyth, (631 -20%) = 504.8

```
=k!kmrd=k-6kc"baton rouge,la,indianapolis,in,columbus,oh,montgomery,al,helena,mt,denver,co,boise,id,austin,tx,boston,ma,albany,ny,tallahassee,fl,santa fe,nm,nashville,tn,trenton,nj,jefferson,mo,richmond,va,pierre,sd,harrisburg,pa,augusta,me,providence,ri,dover,de,concord,nh,montpelier,vt,hartford,ct,topeka,ks,saint paul,mn,juneau,ak,lincoln,ne,raleigh,nc,madison,wi,olympia,wa,phoenix,az,lansing,mi,honolulu,hi,jackson,ms,springfield,il,columbia,sc,annapolis,md,cheyenne,wy,salt lake city,ut,atlanta,ga,bismarck,nd,frankfort,ky,salem,or,little rock,ar,des moines,ia,sacramento,ca,oklahoma city,ok,charleston,wv,carson city,nv"","

```

### Output:

```
['Baton Rouge', 'LA', 'Indianapolis', 'IN', 'Columbus', 'OH', 'Montgomery', 'AL', 'Helena', 'MT', 'Denver', 'CO', 'Boise', 'ID', 'Austin', 'TX', 'Boston', 'MA', 'Albany', 'NY', 'Tallahassee', 'FL', 'Santa Fe', 'NM', 'Nashville', 'TN', 'Trenton', 'NJ', 'Jefferson', 'MO', 'Richmond', 'VA', 'Pierre', 'SD', 'Harrisburg', 'PA', 'Augusta', 'ME', 'Providence', 'RI', 'Dover', 'DE', 'Concord', 'NH', 'Montpelier', 'VT', 'Hartford', 'CT', 'Topeka', 'KS', 'Saint Paul', 'MN', 'Juneau', 'AK', 'Lincoln', 'NE', 'Raleigh', 'NC', 'Madison', 'WI', 'Olympia', 'WA', 'Phoenix', 'AZ', 'Lansing', 'MI', 'Honolulu', 'HI', 'Jackson', 'MS', 'Springfield', 'IL', 'Columbia', 'SC', 'Annapolis', 'MD', 'Cheyenne', 'WY', 'Salt Lake City', 'UT', 'Atlanta', 'GA', 'Bismarck', 'ND', 'Frankfort', 'KY', 'Salem', 'OR', 'Little Rock', 'AR', 'Des Moines', 'IA', 'Sacramento', 'CA', 'Oklahoma City', 'OK', 'Charleston', 'WV', 'Carson City', 'NV']

```

The second parameter for `r` alternates between 5 (`capwords()`) and 1 (`upper()`)
> 4 votes

# Answer
# PowerShell, ~~1038~~ ~~976~~ ~~925~~ ~~904~~ ~~813~~ ~~768~~ ~~758~~ ~~749~~ 745 -20% = 596

```
"labaton rouge;inindianapolis;ohcolumbus;almontgomery;mthelena;codenver;idboise;txaustin;maboston;nyalbany;fltallahassee;nmsanta fe;tnnashville;njtrenton;mojefferson;varichmond;sdpierre;paharrisburg;meaugusta;riprovidence;dedover;nhconcord;vtmontpelier;cthartford;kstopeka;mnsaint paul;akjuneau;nelincoln;ncraleigh;wimadison;waolympia;azphoenix;milansing;hihonolulu;msjackson;ilspringfield;sccolumbia;mdannapolis;wycheyenne;utsalt lake city;gaatlanta;ndbismarck;kyfrankfort;orsalem;arlittle rock;iades moines;casacramento;okoklahoma city;wvcharleston;nvcarson city"-split";"|%{$a=-split$_;$b={$n,$i=$args;if($a[$n]){" "+(""+$a[$n][$i++]).toupper()+$a[$n].substring($i)}};$(&$b(0)2).trim()+$(&$b(3-2)0)+$(&$b(2)0)+","+$_.substring(0,2).toupper()}

```

**Ungolfed:**

```
"labaton rouge;inindianapolis;ohcolumbus;almontgomery;mthelena;codenver;idboise;txaustin;maboston;nyalbany;fltallahassee;nmsanta fe;tnnashville;njtrenton;mojefferson;varichmond;sdpierre;paharrisburg;meaugusta;riprovidence;dedover;nhconcord;vtmontpelier;cthartford;kstopeka;mnsaint paul;akjuneau;nelincoln;ncraleigh;wimadison;waolympia;azphoenix;milansing;hihonolulu;msjackson;ilspringfield;sccolumbia;mdannapolis;wycheyenne;utsalt lake city;gaatlanta;ndbismarck;kyfrankfort;orsalem;arlittle rock;iades moines;casacramento;okoklahoma city;wvcharleston;nvcarson city"-split";"|%{
   $a=-split$_;
   $b={
        $n,$i=$args;
        if($a[$n]){
          " "+
          (""+$a[$n][$i++]).toupper()+
          $a[$n].substring($i)
         }
      };
   $(&$b(0)2).trim()+
   $(&$b(3-2)0)+
   $(&$b(2)0)+
   ","+
   $_.substring(0,2).toupper()
 }

```
> 3 votes

# Answer
## Minkolang 0.7, ~~660~~ ~~705~~ 708 * 0.8 = 566.4

```
99*32-+58*0p467+35*44*55*d8+d5+(99*2-23-r32-p)"baton rouge, laindianapolis, incolumbus, ohmontgomery, alhelena, mtdenver, coboise, idaustin, txboston, maalbany, nytallahassee, flsanta fe, nmnashville, tntrenton, njjefferson, morichmond, vapierre, sdharrisburg, paaugusta, meprovidence, ridover, deconcord, nhmontpelier, vthartford, cttopeka, kssaint paul, mnjuneau, aklincoln, neraleigh, ncmadison, wiolympia, waphoenix, azlansing, mihonolulu, hijackson, msspringfield, ilcolumbia, scannapolis, mdcheyenne, wysalt lake city, utatlanta, gabismarck, ndfrankfort, kysalem, orlittle rock, ardes moines, iasacramento, caoklahoma city, okcharleston, wvcarson city, nv"032-w
48*-o(d","=2&o)oo22$[48*-o]d?.25*o48*-o)

```

Thanks to **Sp3000** for reminding me that I can use `p` to put capital Os in the code!

### Explanation

The bit of the first line before the `"` does nothing but put a `R` (rotate stack) in place of `r` and then replace all of the instances of `o` with `O` on the second line.

After that, it's the list of capitals without newlines and all letters lowercased, which is pushed onto the stack in reverse order by Minkolang. There is a `01w` at the end which is a "wormhole" to the beginning of the second line. All capital letters are outputted by subtracting 32 from the lowercase letter, which is why `48*-` shows up four times.

`48*-O` outputs `B`, then `(` begins a while loop. The top of stack is checked against `,`. If it's not `,`, then `O)` outputs the character and jumps back to the beginning of the loop. If the top of stack *is* `,`, then the program counter jumps over `O)` because of `2&`, a conditional trampoline that jumps two spaces.

Now, I jump when I encounter a `,` because I know the next six characters are `, AB\nC`, which is what the rest of the loop does. There is a check to see if the stack is empty in the middle (after `AB` is printed, before `\nC`): `d?`. If it is, then the conditional trampoline is not taken and the program exits upon hitting the `.`. Otherwise, it's skipped and the loop continues.
> 2 votes

# Answer
# PHP 520 bytes (650 bytes - 20%)

```
foreach(explode(',','baton rouge,indianapolis,columbus,montgomery,helena,denver,boise,austin,boston,albany,tallahassee,santa fe,nashville,trenton,jefferson,richmond,pierre,harrisburg,augusta,providence,dover,concord,montpelier,hartford,topeka,saint paul,juneau,lincoln,raleigh,madison,olympia,phoenix,lansing,honolulu,jackson,springfield,columbia,annapolis,cheyenne,salt lake city,atlanta,bismarck,frankfort,salem,little rock,des moines,sacramento,oklahoma city,charleston,carson city')as$k=>$v)echo ucwords($v).','.strtoupper(substr('lainohalmtcoidtxmanyflnmtnnjmovasdpameridenhvtctksmnaknencwiwaazmihimsilscmdwyutgandkyorariacaokwvnv',$k*2,2)).'_';

```

**Result**

> Baton Rouge,LA\_Indianapolis,IN\_ …

**Ungolfed:**

```
$cities = 'baton rouge,indianapolis,columbus,montgomery,helena,denver,boise,austin,boston,albany,tallahassee,santa fe,nashville,trenton,jefferson,richmond,pierre,harrisburg,augusta,providence,dover,concord,montpelier,hartford,topeka,saint paul,juneau,lincoln,raleigh,madison,olympia,phoenix,lansing,honolulu,jackson,springfield,columbia,annapolis,cheyenne,salt lake city,atlanta,bismarck,frankfort,salem,little rock,des moines,sacramento,oklahoma city,charleston,carson city';
$states = 'lainohalmtcoidtxmanyflnmtnnjmovasdpameridenhvtctksmnaknencwiwaazmihimsilscmdwyutgandkyorariacaokwvnv';

foreach(explode(',',$cities) as $k => $v)
    echo ucwords($v)
         . ','
         . strtoupper(
             substr($states, $k * 2, 2)
         )
         . '_';

```

I tried various ways to compress the string, but in the end all solutions were longer than this straight forward approach.
> 2 votes

# Answer
# Python 2, 658 bytes * 0.8 = 526.4

```
print zip([c.title()for c in"baton rouge.indianapolis.columbus.montgomery.helena.denver.boise.austin.boston.albany.tallahassee.santa fe.nashville.trenton.jefferson.richmond.pierre.harrisburg.augusta.providence.dover.concord.montpelier.hartford.topeka.saint paul.juneau.lincoln.raleigh.madison.olympia.phoenix.lansing.honolulu.jackson.springfield.columbia.annapolis.cheyenne.salt lake city.atlanta.bismarck.frankfurt.salem.little rock.des moines.sacramento.oklahoma city.charleston.carson city".split('.')],[s.upper()for s in map(''.join,zip(*[iter("lainohalmtcoidtxmanyflnmtnnjmovasdpameridenhvtctksmnaknencwiwaazmihimsilscmdwyutgandkyorariacaokwvnv")]*2))])

```

Prints the result as a Python list of Python tuples. They are also enclosed in quotes. This definitely qualifies for the bonus since the only number in the code is 2.

Output:

```
[('Baton Rouge', 'LA'), ('Indianapolis', 'IN'), ('Columbus', 'OH'), ('Montgomery', 'AL'), ('Helena', 'MT'), ('Denver', 'CO'), ('Boise', 'ID'), ('Austin', 'TX'), ('Boston', 'MA'), ('Albany', 'NY'), ('Tallahassee', 'FL'), ('Santa Fe', 'NM'), ('Nashville', 'TN'), ('Trenton', 'NJ'), ('Jefferson', 'MO'), ('Richmond', 'VA'), ('Pierre', 'SD'), ('Harrisburg', 'PA'), ('Augusta', 'ME'), ('Providence', 'RI'), ('Dover', 'DE'), ('Concord', 'NH'), ('Montpelier', 'VT'), ('Hartford', 'CT'), ('Topeka', 'KS'), ('Saint Paul', 'MN'), ('Juneau', 'AK'), ('Lincoln', 'NE'), ('Raleigh', 'NC'), ('Madison', 'WI'), ('Olympia', 'WA'), ('Phoenix', 'AZ'), ('Lansing', 'MI'), ('Honolulu', 'HI'), ('Jackson', 'MS'), ('Springfield', 'IL'), ('Columbia', 'SC'), ('Annapolis', 'MD'), ('Cheyenne', 'WY'), ('Salt Lake City', 'UT'), ('Atlanta', 'GA'), ('Bismarck', 'ND'), ('Frankfurt', 'KY'), ('Salem', 'OR'), ('Little Rock', 'AR'), ('Des Moines', 'IA'), ('Sacramento', 'CA'), ('Oklahoma City', 'OK'), ('Charleston', 'WV'), ('Carson City', 'NV')]

```

I hope this is within the acceptable bounds of formatting.
> 2 votes

# Answer
# Groovy, ~~724~~ 681 - 20% = 545 bytes

```
c={it.capitalize()}
'labaton rouge,inindianapolis,ohcolumbus,almontgomery,mthelena,codenver,idboise,txaustin,maboston,nyalbany,fltallahassee,nmsanta fe,tnnashville,njtrenton,mojefferson,varichmond,sdpierre,paharrisburg,meaugusta,riprovidence,dedover,nhconcord,vtmontpelier,cthartford,kstopeka,mnsaint paul,akjuneau,nelincoln,ncraleigh,wimadison,waolympia,azphoenix,milansing,hihonolulu,msjackson,ilspringfield,sccolumbia,mdannapolis,wycheyenne,utsalt lake city,gaatlanta,ndbismarck,kyfrankfort,orsalem,arlittle rock,iades moines,casacramento,okoklahoma city,wvcharleston,nvcarson city'.split(',').each{it.substring(2).split(' ').each{print c(it) + ' '}println c(it[0])+c(it[3-2])}

```

Inspired by Edc65's clever smushing together of state and city name!
> 2 votes

# Answer
## PowerShell, 627 -20% = 502 bytes

```
[regex]::replace('baton rougela;indianapolisin;columbusoh;montgomeryal;helenamt;denverco;boiseid;austintx;bostonma;albanyny;tallahasseefl;santa fenm;nashvilletn;trentonnj;jeffersonmo;richmondva;pierresd;harrisburgpa;augustame;providenceri;doverde;concordnh;montpeliervt;hartfordct;topekaks;saint paulmn;juneauak;lincolnne;raleighnc;madisonwi;olympiawa;phoenixaz;lansingmi;honoluluhi;jacksonms;springfieldil;columbiasc;annapolismd;cheyennewy;salt lake cityut;atlantaga;bismarcknd;frankfortky;salemor;little rockar;des moinesia;sacramentoca;oklahoma cityok;charlestonwv;carson citynv;','\b\w|..;',{"$args,"[3]+"$args".toupper()})

```

Which is this pattern:

```
[regex]::replace('baton rougela;','\b\w|..;',{"$args,"[3]+"$args".toupper()})

```

Uppercase the single letter after a word boundary, or the double letters before a colon. The `"$args,"[3]` selects either the comma in the case of a double letter state code, or overselects and returns null, and adds the state separators, saving ~50 in separators from the code line.
> 2 votes

# Answer
## Ruby, (925 * 80%) = 740 bytes

```
require "zlib";eval "puts \x5alib::inflate('789c35925db2da300c85dfb50a16a04d98044a203f0ca450faa64b44e2892333b6c394dd57e1b66fdfb1251fe98c8dfb2279637d0323424fef6cc42a07931c4922fc61c0ccfd1c15ab8d624c56b0fd056b4a5e56273ff78ca581b58d1385fb88750e6b6f2363b140d422ac0c6414a2966736a9d305b28182e3cfe57551fc6611c6eb0d32efe6e9cb129eb37f3c476c76ca72f7a1c37a0739cb8b03668d525c55de0a472c0ce47e39ce37b00d24e3c38784871bec28041bbfe6d0e3d12c2a3d9677b21676ec58742b252f6ae566dc15504867e97f0e450d7bba8f7159e20c7b7e3c387c4403fb59986634072849a2951eab024aab533ac17aa39892630d48333127a8a8b34be7b580ca4beafdc4e18da6fca8273baba35f5aa8290e2feb1c635b43333a1afc44dfb1350768dc7b7a6a365703c7c1b3d83f687ec3517b03e3398763f02fdbb1dc194f059cc8b1ed07ac3338d9fb3079e9f062e04cf740134bf2982dca4a5a1d697658d5aa1c4fd89c1648ab9246fef6fed9ea89fe86d596b1aee0fc0cbaf0c3b2ebb028a125a783528cccb855e99f3c121eced086c546e3d8c35f3dcecbfd'.scan(/.{2}/).map {|i|i.hex.chr}.join)"

```

Oof, this one was hard. This is a Zlib compressed string in hex encoded bytes, which is then decompressed, turned into an array of strings by the scan regex, then each string is converted to a decimal integer, then to a character, and finally this array is joined into a string. I might post a better version later that uses a modified base64 encoding.

Though the encoded string may have some instances of 65-90 or 1's, I don't count those because the string is one huge number in hexadecimal. Thus this qualifies for the 20% bonus.
> 1 votes

# Answer
## Python 2, 639 bytes - 20% = 511.2

```
t="labaton rouge,inindianapolis,ohcolumbus,almontgomery,mthelena,codenver,idboise,txaustin,maboston,nyalbany,fltallahassee,nmsanta fe,tnnashville,njtrenton,mojefferson,varichmond,sdpierre,paharrisburg,meaugusta,riprovidence,dedover,nhconcord,vtmontpelier,cthartford,kstopeka,mnsaint paul,akjuneau,nelincoln,ncraleigh,wimadison,waolympia,azphoenix,milansing,hihonolulu,msjackson,ilspringfield,sccolumbia,mdannapolis,wycheyenne,utsalt lake city,gaatlanta,ndbismarck,kyfrankfurt,orsalem,arlittle rock,iades moines,casacramento,okoklahoma city,wvcharleston,nvcarson city".split(",");print[(t[n][:2].upper(),t[n][2:].title())for n in range(50)]

```

The version bellow (675 bytes) has `''.join([w.capitalize()for w in t[n][2:].split()])` in it, which I just discovered can be replace by `.title()`, and is an anonymous function. In both answers, the state abbreviations are attached to the capitals.

```
lambda t="labaton rouge,inindianapolis,ohcolumbus,almontgomery,mthelena,codenver,idboise,txaustin,maboston,nyalbany,fltallahassee,nmsanta fe,tnnashville,njtrenton,mojefferson,varichmond,sdpierre,paharrisburg,meaugusta,riprovidence,dedover,nhconcord,vtmontpelier,cthartford,kstopeka,mnsaint paul,akjuneau,nelincoln,ncraleigh,wimadison,waolympia,azphoenix,milansing,hihonolulu,msjackson,ilspringfield,sccolumbia,mdannapolis,wycheyenne,utsalt lake city,gaatlanta,ndbismarck,kyfrankfurt,orsalem,arlittle rock,iades moines,casacramento,okoklahoma city,wvcharleston,nvcarson city".split(","):[(t[n][:2].upper(),''.join([w.capitalize()for w in t[n][2:].split()]))for n in range(50)]

```
> 1 votes

# Answer
# x86 machine-code - 585 bytes, 468 with bonus

Dissapointed with how large my last entry was, I decided to try something very different this time. Drawing on `insertusernamehere`'s idea of separating the city names from the state names, thus avoiding unnecessary logic and unneeded terminators, I still thought I've gotta be able to make the program smaller than the raw strings are. UPX wouldn't help me to cheat, complaining that the program was already too small. Thinking about compression, I tried to compress the 662 byte text output with WinRar but still only got 543 bytes - and that was without anything to decompress it with. It still seemed far too large, given that it was just the result, without any code.

Then I realized - I'm only using 26 chars for the letters and another 2 for the spaces and the commas. Hmm, that fits into 32, which needs just 5 bits. So, I wrote a quick javascript program to encode the strings, assigning a-z to 0-25 and space and comma got 26 and 27. To keep things simple, every character is encoded in 5 bits, whether it needs this many or not. From there, I just stuck all the bits together and broke them back into byte-sized chunks. This allowed me to pack the 563 bytes of strings into 353 bytes - a saving of 37.5% or some 210 bytes. I didn't quite manage to squeeze the program and data into the same space as just the unpacked data, but I came close enough to be happy.

Hxd view of binary:

```
68 3F 00 68 E8 01 68 4F 03 E8 1C 00 68 22 01 68 27 02 68 B3 03 E8 10 00     -   h?.hè.hO.è..h".h'.h³.è..
BE 83 05 C6 04 00 68 4F 03 68 B3 03 E8 62 00 C3 55 89 E5 81 C5 04 00 8B     -   ¾ƒ.Æ..hO.h³.èb.ÃU‰å.Å..‹
76 02 8B 7E 00 B6 05 30 DB AC B2 08 D0 D0 D0 D3 FE CA FE CE 75 1E 80 FB     -   v.‹~.¶.0Û¬².ÐÐÐÓþÊþÎu.€û
1A 75 05 B3 20 E9 0D 00 80 FB 1B 75 05 B3 2C E9 03 00 80 C3 61 88 1D 47     -   .u.³ é..€û.u.³,é..€Ãaˆ.G
B6 05 30 DB 08 D2 75 D4 FF 4E 04 75 CC 5D C2 06 00 53 B3 62 FE CB 88 DF     -   ¶.0Û.ÒuÔÿN.uÌ]Â..S³bþËˆß
80 C7 19 38 D8 72 08 38 F8 77 04 B3 20 28 D8 5B C3 55 89 E5 81 C5 04 00     -   €Ç.8Ør.8øw.³ (Ø[ÃU‰å.Å..
8B 76 00 31 C0 88 C2 89 C1 AC A8 FF 74 46 80 FA 20 74 35 08 D2 74 31 3C     -   ‹v.1ÀˆÂ‰Á¬¨ÿtF€ú t5.Òt1<
2C 75 30 B4 0E CD 10 89 CB 01 DB 03 5E 02 8A 07 E8 B6 FF CD 10 43 8A 07     -   ,u0´.Í.‰Ë.Û.^.Š.è¶ÿÍ.CŠ.
E8 AE FF CD 10 B0 0D CD 10 B0 0A CD 10 C6 06 4C 03 00 30 D2 41 E9 C1 FF     -   è®ÿÍ.°.Í.°.Í.Æ.L..0ÒAéÁÿ
E8 96 FF B4 0E CD 10 88 C2 E9 B5 FF 5D C2 04 00 58 10 D7 1C 0B 64 C4 E4     -   è–ÿ´.Í.ˆÂéµÿ]Â..X.×..dÄä
0E 77 60 1B 82 AD AC 9B 5A 96 3A A0 90 DE 06 12 28 19 1A 7A CC 53 54 98     -   .w`.‚.¬›Z–: .Þ..(..zÌST˜
D0 29 A4 68 AC 8B 00 19 62 0E 86 49 0B 90 98 3B 62 93 30 1A 35 61 D1 04     -   Ð)¤h¬‹..b.†I..˜;b“0.5aÑ.
50 01 01 CA B5 5B 50 08 26 E6 EA 2E A1 89 B4 34 68 03 40 F7 2D 12 D8 9C     -   P..Êµ[P.&æê.¡‰´4h.@÷-.Øœ
BA 30 34 96 D8 E6 CC CE 61 23 8D 9C 8B 23 41 B1 91 B5 24 76 17 22 44 D8     -   º04–ØæÌÎa#.œ‹#A±‘µ$v."DØ
29 29 A1 BB 0B A5 37 37 60 58 40 DC 6E 60 5A C0 70 4A 44 26 E4 06 CC 1A     -   ))¡».¥77`X@Ün`ZÀpJD&ä.Ì.
29 36 D0 48 F5 42 D6 4D CE 24 6C DC DD A4 85 29 23 27 37 71 40 8E C7 34     -   )6ÐHõBÖMÎ$lÜÝ¤…)#'7q@ŽÇ4
7B 7A 09 18 93 67 04 62 89 06 91 36 C1 43 52 53 06 DF 17 55 03 23 44 4D     -   {z..“g.b‰.‘6ÁCRS.ß.U.#DM
8D D5 24 76 27 34 4E 88 F6 C7 36 6F 22 D0 48 EC E0 8C CA E8 8F 73 73 C8     -   .Õ$v'4NˆöÇ6o"ÐHìàŒÊè.ssÈ
A0 6E 40 43 67 A7 82 8B DA 68 D2 02 9B 5A 1A 27 2D BB 88 16 44 18 FB 60     -    n@Cg§‚‹ÚhÒ.›Z.'-»ˆ.D.û`
06 89 39 BB 72 F0 C7 A0 1B 79 DC 46 A2 FB 58 1B 24 34 DB 3B 9A E5 D1 74     -   .‰9»rðÇ .yÜF¢ûX.$4Û;šåÑt
DA 40 25 49 CD DC 9F 14 34 C5 41 16 3D 89 CB A3 02 80 6C 0D 68 1E E5 A2     -   Ú@%IÍÜŸ.4ÅA.=‰Ë£.€l.h.å¢
5B 11 C9 82 35 A4 DC 80 B9 E9 60 51 34 24 4F 1B 04 D6 06 CC 1B 0A 24 C0     -   [.É‚5¤Ü€¹é`Q4$O..Ö.Ì..$À
44 4A D9 62 06 A8 AE 8C F7 20 2C 8C DA D1 39 AC 9A 8B 84 AD 8C 92 D3 1C     -   DJÙb.¨®Œ÷ ,ŒÚÑ9¬š‹„.Œ’Ó.
86 92 5B 90 05 10 30 8D 9B B6 E5 2C 07 73 01 A1 22 78 D8 8E 08 AC 92 9B     -   †’[...0.›¶å,.s.¡"xØŽ.¬’›
9B B1 02 32 73 74 24 4F 1B                                                  -   ›±.2st$O.

```

Source-code:

```
[section .text]
[bits 16]
[org 0x100]
entry_point:
    push    word 63                 ; no of bytes of packed data = (5/8) * unpacked_length    - rounded up tp nearest byte
    push    word states_packed
    push    word states_unpacked
    call    unpack_bytes

    push    word 290                ; no bytes of packed data
    push    word capitals_packed
    push    word capitals_unpacked
    call    unpack_bytes

    ; ensure there's a terminating null after the capitals
    mov     si, nullTerminator
    mov     [si], byte 0

    ;void outputStrings(char *cities, char *states)
    push    word states_unpacked
    push    word capitals_unpacked
    call    output_strings

;   int 0x20
    ret

;void unpack_states(char *unpackedDest, char *packedInput, int packed_length)
;unpack_capitals:
unpack_bytes:
    push    bp
    mov     bp, sp
    add     bp, 4

    mov     si, [bp + 2]        ; point to the packed input
    mov     di, [bp + 0]        ; point to the output buffer

    mov     dh, 5               ; number of bits remaining until we have a full output byte, ready to be translated from [0..25] --> [A..Z] (+65) or 26-->' ' or 27-->','
    xor     bl, bl              ; clear our output accumalator
.unpack_get_byte:
    lodsb
    mov     dl, 8           ; number of bits remaining in this packed byte before we need another one
.unpack_get_next_bit:
    rcl     al, 1           ; put most significant bit into carry flag
    rcl     bl, 1           ; and put it into the least significant bit of our accumalator
    dec     dl              ; 1 bit less before we need another packed byte
    dec     dh              ; 1 bit less until this output byte is done
    jnz     .checkInputBitsRemaining

.transform_output_byte:
    cmp     bl, 26          ; space is encoded as 26
    jne     .notSpace
    mov     bl, ' '
    jmp     .store_output_byte
.notSpace:
    cmp     bl, 27          ; comma is encoded as 27
    jne     .notComma
    mov     bl, ','
    jmp     .store_output_byte
.notComma:
.alphaChar:
    add     bl, 'a'         ; change from [0..25] to [A..Z]
.store_output_byte:
    mov     [di], bl        ; store it
    inc     di              ; point to the next output element
    mov     dh, 5           ; and reset the count of bits till we get here again
    xor     bl, bl
.checkInputBitsRemaining:
    or      dl,dl           ; see if we've emptied the packed byte yet
    jnz     .unpack_get_next_bit

    dec     word [bp + 4]       ; decrement the number of bytes of input remaining to be processed
    jnz     .unpack_get_byte    ; if we still have some, go back for more

.unpack_input_processed:

    pop     bp
    ret     6

; input:
;       al = char
; outpt:
;       if al if an alpha char, ensures it is in range [capital-a .. capital-z]
toupper:
    push    bx
    mov     bl, 98
    dec     bl              ; bl = 'a'
    mov     bh, bl
    add     bh, 25          ; bh = 'z'
    cmp     al, bl          ;'a'
    jb      .toupperdone
    cmp     al, bh
    ja      .toupperdone
    mov     bl, 32
    sub     al, bl          ;'A' - 'a'
.toupperdone:
    pop     bx
    ret

;void outputStrings(char *cities, char *states)
output_strings:
    push    bp
    mov     bp, sp
    add     bp, 4

    mov     si, [bp + 0]            ; si --> array of cities
    xor     ax, ax
;   mov     [lastChar], al          ; last printed char is undefined at this point - we'll use this to know if we're processing the first entry
    mov     dl, al
;   mov     [string_index], ax      ; zero the string_index too
    mov     cx, ax                  ; zero the string_index too
.getOutputChar:
    lodsb
    test    al, 0xff
    jz      .outputDone             ; if we've got a NULL, it's the string terminator so exit

;   cmp     byte [lastChar], ' '    ; if the last char was a space, we have to capitalize this one
    cmp     dl, ' '                 ; if the last char was a space, we have to capitalize this one
    je      .make_ucase

;   cmp     byte [lastChar], 0
    or      dl, dl                  ; if this is 0, then it's the first char we've printed, therefore we know it should be capitalized
    jz      .make_ucase

    cmp     al, ','                 ; if this is a comma, the city is done, so print the comma then do the state and a crlf, finally, increment the string_index
    jne     .printChar

    mov     ah, 0xe                 ; code for print-char, teletype output
    int     0x10                    ; print the char held in al

;   mov     bx, [string_index]
    mov     bx, cx;[string_index]
    add     bx,bx                   ; x2 since each state is 2 bytes long
    add     bx, [bp+2]              ; bx --> states_unpacked[string_index]
    mov     al, [bx]                ; get the first char of the state
    call    toupper                 ; upper case it
;   mov     ah, 0xe         ;not needed, still set from above
    int     0x10                    ; and print it
    inc     bx

    mov     al, [bx]                ; get the 2nd char of the state
    call    toupper                 ; uppercase it
;   mov     ah, 0xe         ;not needed, still set from above
    int     0x10                    ; and print it

    mov     al, 0x0d                ; print a CRLF
    int     0x10
    mov     al, 0x0a
    int     0x10

    mov     byte [lastChar], 0      ; zero this, so that the first letter of the new city will be capitalized, just like the first char in the string was
    xor     dl, dl                  ; zero this, so that the first letter of the new city will be capitalized, just like the first char in the string was

;   inc     word [string_index]     ; increment our index, ready for the next city's state
    inc     cx  ;word [string_index]        ; increment our index, ready for the next city's state
    jmp     .getOutputChar          ; go back and get the next char of the next city

.make_ucase:
    call    toupper

.printChar:
    mov     ah, 0xe
    int     0x10
;   mov     [lastChar], al
    mov     dl, al
    jmp     .getOutputChar          ; go back and get the next char of the next city

.outputDone:
    pop     bp
    ret     4                       ; return and clean-up the two vars from the stack

[section .data]

; 63 packed bytes, 100 unpacked (saved 37)
states_packed:
    db  01011000b, 00010000b, 11010111b, 00011100b, 00001011b, 01100100b, 11000100b, 11100100b
    db  00001110b, 01110111b, 01100000b, 00011011b, 10000010b, 10101101b, 10101100b, 10011011b
    db  01011010b, 10010110b, 00111010b, 10100000b, 10010000b, 11011110b, 00000110b, 00010010b
    db  00101000b, 00011001b, 00011010b, 01111010b, 11001100b, 01010011b, 01010100b, 10011000b
    db  11010000b, 00101001b, 10100100b, 01101000b, 10101100b, 10001011b, 00000000b, 00011001b
    db  01100010b, 00001110b, 10000110b, 01001001b, 00001011b, 10010000b, 10011000b, 00111011b
    db  01100010b, 10010011b, 00110000b, 00011010b, 00110101b, 01100001b, 11010001b, 00000100b
    db  01010000b, 00000001b, 00000001b, 11001010b, 10110101b, 01011011b, 01010000b

; 290 packed bytes, 463 unpacked (saved 173)
capitals_packed:
    db  00001000b, 00100110b, 11100110b, 11101010b, 00101110b, 10100001b, 10001001b, 10110100b, 00110100b, 01101000b, 00000011b, 01000000b, 11110111b, 00101101b
    db  00010010b, 11011000b, 10011100b, 10111010b, 00110000b, 00110100b, 10010110b, 11011000b, 11100110b, 11001100b, 11001110b, 01100001b, 00100011b, 10001101b
    db  10011100b, 10001011b, 00100011b, 01000001b, 10110001b, 10010001b, 10110101b, 00100100b, 01110110b, 00010111b, 00100010b, 01000100b, 11011000b, 00101001b
    db  00101001b, 10100001b, 10111011b, 00001011b, 10100101b, 00110111b, 00110111b, 01100000b, 01011000b, 01000000b, 11011100b, 01101110b, 01100000b, 01011010b
    db  11000000b, 01110000b, 01001010b, 01000100b, 00100110b, 11100100b, 00000110b, 11001100b, 00011010b, 00101001b, 00110110b, 11010000b, 01001000b, 11110101b
    db  01000010b, 11010110b, 01001101b, 11001110b, 00100100b, 01101100b, 11011100b, 11011101b, 10100100b, 10000101b, 00101001b, 00100011b, 00100111b, 00110111b
    db  01110001b, 01000000b, 10001110b, 11000111b, 00110100b, 01111011b, 01111010b, 00001001b, 00011000b, 10010011b, 01100111b, 00000100b, 01100010b, 10001001b
    db  00000110b, 10010001b, 00110110b, 11000001b, 01000011b, 01010010b, 01010011b, 00000110b, 11011111b, 00010111b, 01010101b, 00000011b, 00100011b, 01000100b
    db  01001101b, 10001101b, 11010101b, 00100100b, 01110110b, 00100111b, 00110100b, 01001110b, 10001000b, 11110110b, 11000111b, 00110110b, 01101111b, 00100010b
    db  11010000b, 01001000b, 11101100b, 11100000b, 10001100b, 11001010b, 11101000b, 10001111b, 01110011b, 01110011b, 11001000b, 10100000b, 01101110b, 01000000b
    db  01000011b, 01100111b, 10100111b, 10000010b, 10001011b, 11011010b, 01101000b, 11010010b, 00000010b, 10011011b, 01011010b, 00011010b, 00100111b, 00101101b
    db  10111011b, 10001000b, 00010110b, 01000100b, 00011000b, 11111011b, 01100000b, 00000110b, 10001001b, 00111001b, 10111011b, 01110010b, 11110000b, 11000111b
    db  10100000b, 00011011b, 01111001b, 11011100b, 01000110b, 10100010b, 11111011b, 01011000b, 00011011b, 00100100b, 00110100b, 11011011b, 00111011b, 10011010b
    db  11100101b, 11010001b, 01110100b, 11011010b, 01000000b, 00100101b, 01001001b, 11001101b, 11011100b, 10011111b, 00010100b, 00110100b, 11000101b, 01000001b
    db  00010110b, 00111101b, 10001001b, 11001011b, 10100011b, 00000010b, 10000000b, 01101100b, 00001101b, 01101000b, 00011110b, 11100101b, 10100010b, 01011011b
    db  00010001b, 11001001b, 10000010b, 00110101b, 10100100b, 11011100b, 10000000b, 10111001b, 11101001b, 01100000b, 01010001b, 00110100b, 00100100b, 01001111b
    db  00011011b, 00000100b, 11010110b, 00000110b, 11001100b, 00011011b, 00001010b, 00100100b, 11000000b, 01000100b, 01001010b, 11011001b, 01100010b, 00000110b
    db  10101000b, 10101110b, 10001100b, 11110111b, 00100000b, 00101100b, 10001100b, 11011010b, 11010001b, 00111001b, 10101100b, 10011010b, 10001011b, 10000100b
    db  10101101b, 10001100b, 10010010b, 11010011b, 00011100b, 10000110b, 10010010b, 01011011b, 10010000b, 00000101b, 00010000b, 00110000b, 10001101b, 10011011b
    db  10110110b, 11100101b, 00101100b, 00000111b, 01110011b, 00000001b, 10100001b, 00100010b, 01111000b, 11011000b, 10001110b, 00001000b, 10101100b, 10010010b
    db  10011011b, 10011011b, 10110001b, 00000010b, 00110010b, 01110011b, 01110100b, 00100100b, 01001111b, 00011011b

[section .bss]
lastChar        resb    1       ; last printed char - used to capitalize chars after a space (i.e the 2nd or third word of a city name)
string_index    resw    1       ; used to index into the array of states, which are each two bytes

states_unpacked         resb 100            ; 50 states, 2 bytes each
capitals_unpacked       resb 464
nullTerminator          resb   1

```
> -1 votes

---
Tags: code-golf, kolmogorov-complexity, restricted-source
---


title: Slices of triangular alphabets

text:
# Question
Title: Slices of triangular alphabets
Given an input number `n` from `1` to `26` (or `0` to `25`), output the alphabet reading left-to-right up to and including that corresponding letter, with `a=1, b=2, c=3, ...`. The twist is the letters must also be repeated vertically corresponding to their position in the alphabet. Odd numbers (when `1`-indexed) should be balanced across the horizontal line, while even numbers should alternate between favoring the top or bottom (you can choose which direction to go first). If you're 0-indexing, then swap odd/even in the previous sentence.

Worded another way -- if the alphabetical value of a letter `?` is `#`, then there should be `#` copies of that letter in the output, all of them in the `#`th column. These letters should be evenly balanced above and below the horizontal line that has the `a`. If the letters cannot be balanced evenly, then alternate having the "extra" letter above and below that line.

Here are the first six outputs (`n = 1,2,3,4,5,6`, 1-indexed, choosing to alternate to the bottom first), separated by newlines, so you can see the pattern. Comments explaining the pattern start with `#`.

```
a         # On a line by itself

ab
 b        # The "extra" letter is below the horizontal

  c
abc       # The 'c' splits evenly
 bc

   d      # Because the 'b' was below, the extra 'd' must be above
  cd
abcd
 bcd

   de
  cde
abcde     # The 'e' balances
 bcde
    e

   def
  cdef
abcdef
 bcdef
    ef
     f    # Since the 'd' was above, the extra 'f' must be below

```

(skip a few to `n=26`)

```
                       xyz
                      wxyz
                   tuvwxyz
                  stuvwxyz
               pqrstuvwxyz
              opqrstuvwxyz
           lmnopqrstuvwxyz
          klmnopqrstuvwxyz
       hijklmnopqrstuvwxyz
      ghijklmnopqrstuvwxyz
   defghijklmnopqrstuvwxyz
  cdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
 bcdefghijklmnopqrstuvwxyz
    efghijklmnopqrstuvwxyz
     fghijklmnopqrstuvwxyz
        ijklmnopqrstuvwxyz
         jklmnopqrstuvwxyz
            mnopqrstuvwxyz
             nopqrstuvwxyz
                qrstuvwxyz
                 rstuvwxyz
                    uvwxyz
                     vwxyz
                        yz
                         z

```

### Rules

* You can choose to output in uppercase or lowercase, but it must be consistent.
* The output cannot have extraneous whitespace, except for an optional trailing newline.
* Either a full program or a function are acceptable.
* The input number can be taken via any suitable format.
* Standard loopholes are forbidden.
* This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

# Answer
# Jelly, ~~20~~ 18 bytes

```
Ḷ&2’×ḶỤØaḣ⁸¤ṫW€UGU

```

Port of my Python answer. Try it online.

EDIT: Dennis saved two bytes by using  (grade up) instead of `Þ` (sort by)!
> 5 votes

# Answer
# Python 2, ~~101~~ 99 bytes

```
r=range(input())
for x in sorted(r,key=lambda x:x*-(x&2)):print bytearray([97+i,32][i<x]for i in r)

```

xsot saved two bytes by realizing `x*-(x&2)` suffices as a sorting key — the bottom half of the resulting image is unaffected due to `sorted` guaranteeing a stable sort.
> 8 votes

# Answer
# Pyth, 26 bytes

A perfect score for a challenge about alphabet.

```
j_C.e<u_G/k2.[.|1Q*hkbdQ<G

```

Try it online!
> 6 votes

# Answer
# Jelly, 25 bytes

```
RØaxŒgz⁶W€;ṚL‘$¡¥/Ṛ⁸H¤¡j⁷

```

Try it online! or verify all test cases.
> 4 votes

# Answer
## JavaScript (ES6), ~~127~~ 126 bytes

```
n=>[...Array(n).keys()].sort((a,b)=>a*~-(a&2)-b*~-(b&2)).map(i=>` `.repeat(i)+`abcdefghijklmnopqrstuvwxyz`.slice(i,n)).join`\n`

```

Uses @Lynn's sort trick. Writing out the whole alphabet was two bytes cheaper than calculating it. Edit: Saved 1 byte thanks to @ETHproductions because I forgot to note that `\n` actually represents the literal newline character. (I don't like putting literal newlines in my answer when the line is so long.)
> 2 votes

---
Tags: code-golf, ascii-art
---


title: Keep nonzeros and their neighbours

text:
# Question
Title: Keep nonzeros and their neighbours
*Taken from this question at Stack Overflow. Thanks also to @miles and @Dada for suggesting test inputs that address some corner cases.*

### The challenge

Given an array of integer values, remove all zeros that are not flanked by some nonzero value.

Equivalently, an entry should be kept either if it's a nonzero or if it's a zero that is immediately close to a nonzero value.

The entries that are kept should maintain in the output the order they had in the input.

### Example

Given

```
[2 0 4 -3 0 0 0 3 0 0 2 0 0]

```

the values that should be removed are marked with an `x`:

```
[2 0 4 -3 0 x 0 3 0 0 2 0 x]

```

and so the output should be

```
[2 0 4 -3 0 0 3 0 0 2 0]

```

### Rules

The input array may be empty (and then the output should be empty too).

Input and output formats are flexible as usual: array, list, string, or anything that is reasonable.

Code golf, fewest best.

### Test cases

```
[2 0 4 -3 0 0 0 3 0 0 2 0 0] -> [2 0 4 -3 0 0 3 0 0 2 0]
[] -> []
[1] -> [1]
[4 3 8 5 -6] -> [4 3 8 5 -6]
[4 3 8 0 5 -6] -> [4 3 8 0 5 -6]
[0] -> []
[0 0] -> []
[0 0 0 0] -> []
[0 0 0 8 0 1 0 0] -> [0 8 0 1 0]
[-5 0 5] -> [-5 0 5]
[50 0] -> [50 0]

```

# Answer
> 7 votes
# MATL, 8 bytes

```
tg3:Z+g)

```

Output is a string with numbers separated by spaces. An empty array at the output is displayed as nothing (not even a newline).

Try it online! Or verify all test cases.

### Explanation

The code converts the input to logical type, i.e. nonzero entries become `true` (or `1`) and zero entries become `false` (or `0`). This is then convolved with the kernel `[1 2 3]`. A nonzero value causes a nonzero result at that position and at its neighbouring positions. Converting to logical gives `true` for values that should be kept, so indexing the input with that produces the desired output.

```
t    % Input array implicitly. Duplicate
g    % Convert to logical: nonzero becomes true, zero becomes false
3:   % Push array [1 2 3]
Z+   % Convolution, keeping size of first input
g    % Convert to logical
)    % Index into original array. Implicitly display

```

# Answer
> 16 votes
## JavaScript (ES6), 35 bytes

```
a=>a.filter((e,i)=>e|a[i-1]|a[i+1])

```

Works on floats too for two extra bytes.

# Answer
> 10 votes
## Python, 50 bytes

```
f=lambda l,*p:l and l[:any(l[:2]+p)]+f(l[1:],l[0])

```

A recursive function that takes a tuple. Includes the first element if there's a nonzero value among either the first two elements or the previous value stored from last time. Then, removes the first element and recurses. The previous element is stored in the singleton-list `p`, which automatically packs to list and starts as empty (thanks to Dennis for 3 bytes with this).

---

55 bytes:

```
lambda l:[t[1]for t in zip([0]+l,l,l[1:]+[0])if any(t)]

```

Generates all length-3 chunks of the list, first putting zeroes on the start and end, and takes the middles elements of those that are not all zero.

An iterative approach turned out longer (58 bytes)

```
a=0;b,*l=input()
for x in l+[0]:a|b|x and print(b);a,b=b,x

```

This doesn't exactly work because `b,*l` needs Python 3, but Python 3 `input` gives a string. The initialization is also ugly. Maybe a similar recursive approach would work.

Unfortunately, the indexing method of

```
lambda l:[x for i,x in enumerate(l)if any(l[i-1:i+2])]

```

doesn't work because `l[-1:2]` interprets `-1` as the end of the list, not a point before its start.

# Answer
> 10 votes
## Haskell, ~~55~~ 48 bytes

```
h x=[b|a:b:c:_<-scanr(:)[0]$0:x,any(/=0)[a,b,c]]

```

Usage example: `h [0,0,0,8,0,1,0,0]` -\> `[0,8,0,1,0]`.

`scanr` rebuilds the input list `x` with an additional `0` at the start and end. In each step we pattern match 3 elements and keep the middle one if there's at least one non-zero element.

Thanks @xnor for 7 bytes by switching from `zip3` to `scanr`.

# Answer
> 8 votes
# Matlab, ~~29~~ 27 bytes

The input must consist of a `1*n` matrix (where `n=0` is possible). (It will throw an error for `0*0` matrices.)

```
@(a)a(conv(a.*a,1:3,'s')>0)

```

> Convolution is the key to success.

# Answer
> 6 votes
# J, ~~17~~ 14 bytes

```
#~0<3+/\0,~0,|

```

Saved 3 bytes with help from @Zgarb.

## Usage

```
   f =: #~0<3+/\0,~0,|
   f 2 0 4 _3 0 0 0 3 0 0 2 0 0
2 0 4 _3 0 0 3 0 0 2 0
   f ''

   f 0 0 0 8 0 1 0 0
0 8 0 1 0

```

## Explanation

```
#~0<3+/\0,~0,|  Input: array A
             |  Get the absolute value of each in A
           0,   Prepend a 0
        0,~     Append a 0
    3  \        For each subarray of size 3, left to right
     +/           Reduce it using addition to find the sum
  0<            Test if each sum is greater than one
                (Converts positive values to one with zero remaining zero)
#~              Select the values from A using the previous as a mask and return

```

Try it here.

# Answer
> 5 votes
# Python 3, 55 bytes

```
lambda s:[t[1]for t in zip([0]+s,s,s[1:]+[0])if any(t)]

```

# Answer
> 5 votes
# Jolf, 14 bytes

Now that I think of it, Jolf is the Java of golfing languages. *sighs* Try it here.

```
ψxd||H.nwS.nhS

```

## Explanation

```
ψxd||H.nwS.nhS
ψxd             filter input over this function
   ||           or with three args
     H           the element
      .nwS       the previous element
          .nhS   or the next element

```

# Answer
> 4 votes
# Jelly, 9 bytes

```
0,0jo3\Tị

```

Try it online! or verify all test cases.

### How it works

```
0,0jo3\Tị  Main link. Argument: A (array)

0,0        Yield [0, 0].
   j       Join, separating with A. This prepends and appends a 0 to A.
    o3\    Reduce each group of three adjacent integers by logical OR.
       T   Truth; get the indices of all truthy results.
        ị  At-index; retrieve the elements of A at those indices.

```

# Answer
> 4 votes
## Perl, 34 + 1 (`-p` flag) = 35 bytes

```
s/([^1-9]0 |^)\K0 ?(?=0|$)//&&redo

```

Needs -p flag to run. Takes a list of number as imput. For instance :

```
perl -pe 's/([^1-9]0 |^)\K0 ?(?=0|$)//&&redo' <<< "0 0 0 8 0 1 0 0
0 0 0
-5 0 5"

```

# Answer
> 4 votes
## Haskell, 48 bytes

```
p%(h:t)=[h|any(/=0)$p:h:take 1t]++h%t
p%e=e
(0%)

```

Looks at the previous element `p`, the first element `h`, and the element after (if any), and if any are nonzero, prepends the first element `h`.

The condition `any(/=0)$p:h:take 1t` is lengthy, in particular the `take 1t`. I'll look for a way to shorten it, perhaps by pattern matching.

# Answer
> 4 votes
# Retina, ~~42~~ ~~35~~ 33 bytes

**7 bytes thanks to Martin Ender.**

```
(?<=^|\b0 )0(?=$| 0)

 +

^ | $

```

The last line is necessary.

Verify all testcases at once. (Slightly modified to run all testcases at once.)

Looks like the perfect language to do this in... still got defeated by most of the answers.

# Answer
> 3 votes
# Mathematica, 43 bytes

```
ArrayFilter[If[#.#>0,#[[2]],Nothing]&,#,1]&

```

# Answer
> 3 votes
# C, 96 bytes

Call `f()` with a pointer to the list of integers, and a pointer to the size of the list. The list and size are modified in-place.

```
i,t,e,m;f(int*p,int*n){int*s=p;for(i=m=e=0;i++<*n;s+=t=m+*s||i<*n&&p[1],e+=t,m=*p++)*s=*p;*n=e;}

```

Try it on ideone.

# Answer
> 3 votes
# Brachylog, ~~44~~ 38 bytes

```
,0gL:?:Lc:1fzbh.
~c[A:.:B],[0:0:0]'.l3

```

Try it online!

This language is good as proving things, which is what we will use.

### Predicate 0 (main predicate)

```
,0gL:?:Lc:1fzbh.
 0gL               [0] = L    (assignment works both ways)
   L:?:Lc          [L:input:L] = temp
         :1f       find all solutions of predicate 1 with temp as input
            zbh.   then transpose and take the middle row and assign to output

```

### Predicate 1 (auxiliary predicate)

```
~c[A:.:B],[0:0:0]'.l3
~c[A:.:B]                 input is in the form of [A:output:B]
         ,                and
          [0:0:0]'.       output is not [0:0:0]
                  .l3     and length of output is 3

```

# Answer
> 2 votes
# Matlab with Image Processing Toolbox, 27 bytes

```
@(a)a(~imerode(~a,~~(1:3)))

```

This is an anonymous function.

Example use:

```
>> @(a)a(~imerode(~a,~~(1:3)))
ans =
    @(a)a(~imerode(~a,~~(1:3)))
>> ans([0 0 0 8 0 1 0 0])
ans =
     0     8     0     1     0

```

# Answer
> 2 votes
# Bash + GNU utils, 25

```
grep -vC1 ^0|grep -v \\-$

```

Accepts input as a newline-separated list.

Ideone \- with test driver code added to run all testcases together by converting to/from space-separated and newline-separated.

# Answer
> 2 votes
# Cheddar, 78 bytes

```
a->([[]]+a.map((e,i)->e|(i?a[i-1]:0)|(i-a.len+1?a[i+1]:0)?[e]:[])).reduce((+))

```

Test suite.

Cheddar has no filter, so filtering is done by wrapping the elements we want and transforming the elements we don't want into empty arrays, and then concatenate everything.

For example, `[0,0,0,8,0,1,0,0]` becomes `[[],[],[0],[8],[0],[1],[0],[]]`, and then the concatenated array would be `[0,8,0,1,0]`.

# Answer
> 1 votes
# APL, 14 bytes

```
{⍵/⍨×3∨/0,⍵,0}

```

Test:

```
      {⍵/⍨×3∨/0,⍵,0}2 0 4 ¯3 0 0 0 3 0 0 2 0 0
2 0 4 ¯3 0 0 3 0 0 2 0

```

Explanation:

* `0,⍵,0`: add a zero to the beginning and the end of ⍵
* `×3∨/`: find the sign of the GCD of every group of three adjacent numbers (this will be 0 if they are all zero and 1 otherwise).
* `⍵/⍨`: select all the items from ⍵ for which the result was 1.

# Answer
> 1 votes
# Brain-Flak 142 bytes

Try it online!

```
(<()>)(()){{}([]<([]){{}({}<>)<>({}<>)<>({}<>)<>(<>({}<>)<>({}<>)<>({})<>){{}((<()>))}{}{}([][()])}{}{}<>{}([]){{}({}<>)<>([])}{}<>>[[]])}{}{}

```

## Explanation

```
(<()>)                    #Pad the top with an extra zero
(()){{}([]<...>[[]])}{}   #Until the stack height remains the same
 ([]){{}...([][()])}{}    #Until the stack height is one
  ({}<>)<>                #Move the top three to the other stack
  ({}<>)<>
  ({}<>)<>
  (...)                   #Push the sum of the top three
   <>({}<>)               #Move the second and third back
   <>({}<>)
   <>({})<>               #Leave the top of the stack
  {{}...}{}               #If the sum is not zero
   ((<()>))               #Add a buffer to the top of the stack
  {}                      #Pop the buffer/middle value
 {}                       #Remove extra zero
 <>                       #Switch to the off stack
 {}                       #Remove extra zero
 ([]){{}({}<>)<>([])}{}<> #Move the entire off stack back

```

# Answer
> 1 votes
# Ruby 2.x, 63 bytes

```
f=->(x){x.select.with_index{|y,i|x[i-1].to_i|y|x[i+1].to_i!=0}}

```

Credit where it is due, this is essentially a port of Neil's superior ES6 answer.

It's also my first pcg submission. yay.

---
Tags: code-golf, number, array
---


title: Place a stone on an empty Go board

text:
# Question
Title: Place a stone on an empty Go board
*See also: Make a move on a Go board.*

# Task

Go is a board game where two players (Black and White) place stones on the intersections of grid lines on a 19×19 board. Black moves first — for example, on D4:

In this challenge, you must take a Go board coordinate like `D4` as input, and output an ASCII representation of a board with the first move played at the given point.

> ***Note that there is no column I.*** This is, historically, to reduce confusion with J and L.

This output consists of 19 lines, each containing 19 characters. The point with the stone on it is marked `O`. Empty points on the board are shown as `.`, except for the nine star points (at `D4`, `D10`, `D16`, `K4`, `K10`, `K16`, `Q4`, `Q10`, and `Q16`), which are marked `*`.

For example, given `F5` as an input, your answer’s output must be:

```
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
.....O.............
...*.....*.....*...
...................
...................
...................

```

And given `Q16` as input, your output must be:

```
...................
...................
...................
...*.....*.....O...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................

```

# Rules

* You may write a function that takes the coordinate as an argument, or a program that reads the coordinate from the command line or from `STDIN`.
* You may choose to accept input either in lower-case or upper-case, but your answer doesn’t need to handle both.
* The input is *always* a single string like `a1` or `T19`, never a string + number or two strings.
* If you write a full program, your answer must be printed to `STDOUT` as a string, optionally followed by a trailing newline. If your answer is a function, you may print to `STDOUT`, **or** return a string, **or** return an array/list of strings (rows), **or** return a two-dimensional array or nested list of characters.
* This is . The shortest answer in bytes wins.

# Answer
# MATL, 33 bytes

```
'*O.'19: 6\4=&*Hj1&)Uw64-t8>-&(P)

```

**Try it online!**

### Explanation

```
'*O.'    % Push string with needed characters. Will be indexed into
19:      % Push numeric vector [1 2 ... 19]
6\4=     % 1 for values that equal 4 mod 6, 0 for the rest
&*       % Multiply by transposed version of itself with broadcast. This gives
         % the 19×19 board with 0 instead of '.' and 1 instead of '*'
H        % Push 2. This will correspond to 'O' (stone)
j        % Input string, such as 'Q16'
1&)      % Split into its first char ('Q') and then the rest ('16')
U        % Convert to number (16)
w        % Swap, to move 'Q' to top
64-      % Subtract 64. Thus 'A' gives 1, 'B' gives 2 etc
t8>-     % Duplicate. Subtract 1 if it exceeds 8. This corrects for missing 'I'
&(       % Fill a 2 at coordinates given by the number and the letter
P        % Flip upside down, because matrix coordinates start up, not down
)        % Index the string '*O.' with the 19×19 array containing 0,1,2.
         % Implicitly display

```
> 9 votes

# Answer
# C, ~~212~~ ~~195~~ ~~193~~ ~~181~~ ~~171~~ ~~132~~ ~~103~~ 98 bytes

*Saved 1 byte thanks to @FryAmTheEggman, 5 bytes thanks to @orlp*

Call `f()` with the position to play (must be capitalized), and it prints out the resulting board.

```
i;f(char*p){for(i=380;i--;)putchar(i%20?i^20*atoi(p+1)+64-*p+(*p>72)?i%6^4|i/20%6^3?46:42:79:10);}

```

Try it on ideone.
> 16 votes

# Answer
## C (gcc), ~~132~~ ~~128~~ 109

```
i;m;f(char*s){for(i=380;i--;putchar(m?m^84-*s+(*s>73)|(i/20+1)^atoi(s+1)?m%6^4|i/20%6^3?46:42:79:10))m=i%20;}

```

Ideone

A function that prints the board to STDOUT. Requires the letter coordinate to be capital. Printing in one loop seems to be slightly shorter than the previous nested loop approach.
> 9 votes

# Answer
## MATLAB, 135 bytes

A first attempt, nothing clever, just to see how much better others can do:

```
function go(a)
b=repmat('.',19);
b(4:6:end,4:6:end)='*';
a=sscanf(a,'%c%d');
a(1)=a(1)-64;
if a(1)>8
a(1)=a(1)-1;
end
b(20-a(2),a(1))='0'

```

Usage:

```
go('T19')

```
> 7 votes

# Answer
# Ruby, ~~93~~ 91 bytes

Takes input on the command line, e.g. `$ ruby script.rb Q16`.

```
19.downto(1){|c|puts ([*?A..?T]-[?I]).map{|d|d+c.to_s==$*[0]??O:"DKQ"[d]&&c%6==4??*:?.}*""}

```

Test it on repl.it (wrapped in a lambda there since repl.it doesn't take command line arguments: https://repl.it/CkvT/1

## Ungolfed

```
19.downto(1) do |row|
  puts ([*?A..?T] - [?I]).map {|column|
    if column + row.to_s == ARGV[0]
      "O"
    elsif "DKQ"[column] && row % 6 == 4
      "*"
    else
      "."
    end
  }.join
}

```
> 7 votes

# Answer
## Go, ~~319~~ 286 bytes

```
import(."strconv"
."strings")
func g(c string)(s string){p:=SplitN(c,"",2)
n,_:=Atoi(p[1])
for i:=19;i>0;i--{
for j:= 'a';j<'t';j++{
if j=='i'{
}else if n==i&&ContainsRune(p[0],j){s+="o"
}else if((i==4||i==10||i==16)&&(j=='d'||j=='k'||j=='q')){s+="*"
}else{s+="."}}
s+="\n"}
return}

```

Probably golfable quit a bit, i'm a begginner
> 6 votes

# Answer
# Ruby, ~~130~~ ~~128~~ 121 + 3 (`-n` flag) = 124 bytes

Switched `-p` to `-n` because `puts b` is one byte shorter than `$_=b*$/`

```
~/(.)(.+)/
b=(1..19).map{?.*19}
(a=3,9,15).map{|i|a.map{|j|b[i][j]=?*}}
b[19-$2.to_i][([*?A..?T]-[?I]).index$1]=?o
puts b

```
> 4 votes

# Answer
# Python, ~~148~~ ~~145~~ ~~136~~ ~~130~~ ~~121~~ ~~119~~ 116 Bytes

*-3 Bytes thanks to @RootTwo*

```
lambda x,r=range(19):[[".*o"[[i%6==j%6==3,2][j==ord(x[0])-(x>"I")-65and-~i==int(x[1:])]]for j in r]for i in r[::-1]]

```

anonymous lambda function, takes input of the form "A1" (big letters) and outputs a list of lists of chars (len==1 strings in Python)
> 4 votes

# Answer
# F#, ~~241 237 225 216 214~~ 211 bytes

```
let G(c:string)=for k=1 to 380 do printf(if k%20=0 then"\n"elif"_ABCDEFGHJKLMNOPQRST".IndexOf c.[0]=k%20&&19-k/20=int(c.Substring 1)then"o"elif(k%20=4||k%20=10||k%20=16)&&(k/20=3||k/20=9||k/20=15)then"*"else".")

```

Tricky one this one ... I wonder if it can be made shorter.

Edit: fixed a bug, added numbers some places removed numbers in others, somehow ended up with the same count. ~~Might try shuffling numbers around later~~  Done.

Edit2: saved more bytes by spelling out one of the conditionals, counter intuitively.

Edit3: Fixed another bug: should work now for pieces on the last rank and managed to save two bytes while I am at it, somehow.

Try it online
> 4 votes

# Answer
## \>\<\>, ~~98~~ 96 bytes

```
'_U'i-:b)-0\
+*a$%cv?(0:i<
{*+{4*\+
+4gf-o>1-:?!;:{:}=3*&::aa+%::0=2*&+&6%1-}-aa+,6%{*9=&
=9^^

```

Note that there is an `0x14` in the first row after the first `'`, and an `0x19` between the `9` and the first `^` of the last line. Try it online!

The input is mapped so that `A-T` become `1-19` (with 0 denoting an imaginary "newline" column) and the integer row number is decremented by 1. The program does a loop from 379 down to 0, choosing a char from the bottom row as it goes (offset by 15, to account for the fact that you can't enter a literal newline in the codebox). Newlines are checked via `i % 20 == 0`, and star points are checked by `((i%20-1)%6)*((i/20)%6) == 9`.
> 4 votes

# Answer
## Batch, ~~322~~ ~~310~~ 308 bytes

```
@echo off
set/pi=
set/aa=0,b=1,c=2,d=3,e=4,f=5,g=6,h=7,j=8,k=9,l=10,m=11,n=12,o=13,p=14,q=15,r=16,s=17,t=18,x=%i:~1%-1,y=%i:~,1%,z=y+1
for /l %%r in (18,-1,0)do call:l %%r
exit/b
:l
set s=...*.....*.....*...
call set t=%%s:~%1,1%%
if %x%==%1 call set s=%%s:~,%y%%%o%%s:~%z%%%
call echo %%s:.*=.%t%%%

```

Explanation: Starts by prompting for the stone on stdin. Then, sets variables for each possible column, so that it can evaluate the first character of the stone as a variable to get the `y` coordinate. Subtracts 1 from the `x` coordinate because it's 1-indexed and we want 0-indexed and also computes `z=y+1` as it will need that later. Then, loops `r` from 18 down to 0 for each row. Takes the string `...*.....*.....*...` and extracts the character at the `r`th position for later. On the `x`th row, the `y`th character is replaced with an `o`. Finally, the `.*`s are replaced with a `.` plus the previously extracted character; this is a no-op on rows 4, 10 and 16 but this is the shortest way to achieve that. (I have to use `.*` because replacing `*` is apparently illegal in Batch.)
> 3 votes

# Answer
## Perl, 132 bytes

*-3 bytes thanks to @Dom Hastings*

```
@v=eval"[('.')x19],"x19;@{$v[$_]}[@t]=("*")x3for@t=(3,9,15);pop=~/\d+/;$v[19-$&][($t=ord$`)-65-($t>73)]=O;map{say}map{join"",@$_}@v;

```

Takes command line input. Needs `-M5.010` tu run. For instance :

```
$ cat go_board.pl
@v=eval"[('.')x19],"x19;@{$v[$_]}[@t]=("*")x3for@t=(3,9,15);pop=~/\d+/;$v[19-$&][($t=ord$`)-65-($t>73)]=O;map{say}map{join"",@$_}@v;
$ perl -M5.010 go_board.pl Q16

```

I think this could be shorter, but I couldn't figure out how... please let me know if you do!
> 3 votes

# Answer
# Retina, ~~134~~ ~~129~~ 122 bytes

**11 bytes thanks to Martin Ender, and for inspiration of 1 more.**

```
S2=`
[K-S]
1$&
T`xL`d9d
.+
$*
$
aaab
a
bbbcbb
b|c
¶$0
c
ddd.
d
...*..
b
19$*.
1(1)*¶1(1)*¶((?<-2>.+¶)*(?<-1>.)*).
$3O
O^$`

```

Try it online!
> 3 votes

# Answer
## PowerShell v2+, ~~157~~ 152 bytes

```
$x,$y=[char[]]$args[0];$a=,0*19;0..18|%{$a[$_]=,'.'*19};3,9,15|%{$i=$_;3,9,15|%{$a[$_][$i]='*'}};$a[-join$y-1][$x-65-($x-gt73)]='O';$a[18..0]|%{-join$_}

```

<sub>*(I think I ran into some sort of weird glitch with the comma-operator, so the array construction is a bit longer than it should be)*</sub>

Takes input as an uppercase string via `$args[0]`, casts it as a char-array, stores the first letter into `$x` and the remaining letters into `$y`. This effectively splits the input into letter/number.

We then construct our multidimensional array `$a`. We pre-populate an array of size `19` with `0`s using the comma-operator. We then loop `0..18` to make each element `$a[$_]` equal instead an array of periods, again using the comma operator. *(NB - In theory, this should be able to be condensed to `$a=,(,'.'*19)*19`, but that doesn't seem to work right with the indexing assignment ... I wound up getting whole columns set to `*`)*

Next, we loop twice over `3,9,15` to set the corresponding elements to `*`. We then index into it in the right spot to set the stone `O`. To do so, we subtract `65` from `$x` (i.e, ASCII "A" is 65, and we're zero-indexed), and subtracts an additional one using a Boolean-to-int cast if `$x` is bigger than `73` (i.e., ASCII "I").

Now, our output is reversed (i.e., the upper-left would be `A1`), so we need to reverse the array with `$a[18..0]`. Finally, we output each line `-join`ed together to form a string.
> 2 votes

# Answer
# \>\<\>, 124 bytes

Uses the exact same approach as my C answer. Input must be a capital letter followed by a decimal number.

```
88*i:&-&'I')+0 v
*a&-'0'v!?)0:i&<+
+**2a&~/*a'&'&
:;!?:-1<o'O'v!?=&:&
{*?!v'*'o63.>:6%4=}:a4*+'x'%aa*)
*2a:/  av?%
.37o<'.'<

```

Try it online!

## Explanation:

```
88*i:&-&'I')+0 v         'Push 64-<first input char>+(<first input char> > 'I')
*a&-'0'v!?)0:i&<+        'Set register to 0, parse decimal integer into register.
+**2a&~/*a'&'&           'Pop the -1 (EOF) from stack, multiply register by 20.
                         'Add result of first line to register.
                         'Push 380 onto stack.
:;!?:-1<o'O'v!?=&:&      'Main loop, while top of stack is not 0.
                         'Subtract 1 from top of stack (loop counter)
                         'If current index is the playing piece index, print 'O'
{*?!v'*'o63.>:6%4=}:a4*+'x'%aa*)
                         'If (index%6)=4 and (index+40)%120>100, print '*'
*2a:/  av?%              'If (index%20)=0, print newline
.37o<'.'<                'Otherwise, print '.'

```
> 2 votes

# Answer
## JavaScript, 138 bytes

```
s=>[...t="...*.....*.....*..."].map((c,i)=>t.replace(/\*/g,c).replace(/./g,(c,j)=>x-j|19-i-s.slice(1)?c:'o'),x=parseInt(s[0],36)*.944-9|0)

```

Returns an array of strings. Explanation:

```
s=>[...                         Parameter
 t="...*.....*.....*..."        Pattern of lines 4, 10 and 16
].map((c,i)=>                   Loop 19 times
 t.replace(/\*/g,c)             Change the `*` to `.` on other lines
  .replace(/./g,(c,j)=>         Loop over each character
   x-j|19-i-s.slice(1)?c:'o'),  Change to o at the appropriate position
 x=parseInt(s[0],36)*.944-9|0)  Compute the column number from the letter

```
> 1 votes

# Answer
# R, ~~169~~ 161 bytes

```
f=function(p){S=substr;N=rep(".",114);N[61+6*0:2]="*";M=matrix(N,19,19);M[(S(p,2,3):1)[1],which(LETTERS[-9]==S(p,1,1))]="O";for(i in 19:1)cat(M[i,],"\n",sep="")}

```

With indents and newlines:

```
f=function(p){
    S=substr
    N=rep(".",114) # 6 lines of dots
    N[61+6*0:2]="*" # Place the hoshis
    M=matrix(N,19,19) # Make the 19x19 board using vector recycling
    M[(S(p,2,3):1)[1],  #grab and force coerce the row number to integer
      which(LETTERS[-9]==S(p,1,1))]="O" #Place the first stone
    for(i in 19:1) cat(M[i,],"\n",sep="")
}

```

Usage:

```
> f("A19")
O..................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................
> f("D4")
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...O.....*.....*...
...................
...................
...................
> f("K10")
...................
...................
...................
...*.....*.....*...
...................
...................
...................
...................
...................
...*.....O.....*...
...................
...................
...................
...................
...................
...*.....*.....*...
...................
...................
...................

```
> 1 votes

# Answer
# Lua, 187 Bytes

```
function g(i)i:gsub("(%a+)(%d+)",function(a,b)q=string.byte(a)-64 r=b+0 end)for x=1,19 do s=""for y=1,19 do s=s..(x+y*19==r+q*19 and"o"or(x-4)%6+(y-4)%6==0 and"*"or"-")end print(s)end end

```

I don't feel too bad about 187 for this particular project. Lua still comes out as very clunky for Golfing, but I'm pretty proud of how far I can go with it.
> 1 votes

# Answer
# PHP, 280 268 263 261 255 218 216 bytes

```
<?php $a=ucfirst($argv[1]);$x=substr($a,0,1);$y=substr($a,1);$s=['DKQ',4,16,10];$i=85;while(64<$i--){$j=0;while($j++<20){echo($x==chr($i)&&$y==$j)?'O':((strpos($s[0],chr($i))>-1&&in_array($j,$s))?'*':'.');}echo"\n";}

```

My first golf.

Usage:
Save as a PHP file and call it by `php filename.php coordinate` e.g. `php go.php k13`
> 1 votes

---
Tags: code-golf, ascii-art, go
---


title: Multiplify a number

text:
# Question
Title: Multiplify a number
# Challenge description

*Multiplification* (totally not a made-up word) is a process in which you take two positive integers: `a` and `b`, and produce another integer which is equal to `a` repeated ("glued together") `b` times. For example, multiplifying `3` by `7` gives `3333333`. Similarly, `103` multiplified by `5` is `103103103103103`.

In this challenge, given two positive integers `a` and `b`, output `a` multiplified by `b`. The catch is, you can't use string operations to generate the number - it has to be done in a purely mathematical way. You may only use operators for addition (`+`), subtraction (`-`), multiplication (`*`), integer division (`/`, `//`, `div`), modulo operation (`%`, `mod`) and binary operations (`&`, `^`, `|`, `<<`, `>>` etc.). It's not possible to do in every language, since it has to support arbitrary precision integers.

# Sample inputs / outputs

```
10, 4   | 10101010
3, 9    | 333333333
3737, 2 | 37373737
993, 1  | 993
8888, 8 | 88888888888888888888888888888888

```

# Answer
## Python 2, 48 bytes

```
c,n=input();a=1
while n/a:a*=10
print a**c/~-a*n

```

Arithmetic!

Take number `n` and repetition count `c`. First, computes `a=10**num_digits(n)` as the smallest power of 10 above `a`. Then, the floor division `a**c/(a-1)` gives a number of the form `1001001001001` with `c` ones, spaced apart by the digit-length of `n`. Multiplying by `n` then replaces each `1` with `n`, giving `c` concatenated copies of `n`.

A same-length recursive version:

```
f=lambda c,n,a=10:a**c/~-a*n*(a>n)or f(c,n,a*10)

```

This one has to start at `a=10` because `a=1` causes a division-by-zero error.
> 3 votes

# Answer
# Brachylog, 9 bytes

```
jL,?h:.cL

```

Try it online!

### Explanation

The `j` operator concatenates the first thing in an array to itself as many times as the second thing in the array.

In other words, `[10:2]` would produce `101010`.

This operator uses integer in the implementation so is completely usable.

However, it is one concatenation too many.

Therefore, we use the ability of Brachylog to prove things to deal with this:

```
jL,?h:.cL
jL          input after being treated by the j operator yields L
  ,         and
   ?h:.cL   first element of input concatenated with output is L

```
> 2 votes

# Answer
## Java 8 lambda, 268 characters

Arbitrary precision ruins everything, here are the BigIntegers:

```
import static java.math.BigInteger.*;import java.math.BigInteger;(a,b)->{BigInteger r=ZERO;int d=(int)(Math.log(2)/Math.log(10)*a.bitLength()+1);if(TEN.pow(d-1).compareTo(a)>0)d--;while((b=b.subtract(ONE)).compareTo(ZERO)>=0)r=r.multiply(TEN.pow(d)).add(a);return r;}

```

And here the ungolfed version:

```
import java.math.BigInteger;

import static java.math.BigInteger.*;

public class Q89322 {

    static BigInteger expand(BigInteger a, BigInteger b) {
        BigInteger result = ZERO;

        int digitCount = (int) (Math.log(2) / Math.log(10) * a.bitLength() + 1);
        if (TEN.pow(digitCount - 1).compareTo(a) > 0) {
            digitCount--;
        }
        while ((b = b.subtract(ONE)).compareTo(ZERO) >= 0) {
            result = result.multiply(TEN.pow(digitCount)).add(a);
        }
        return result;
    }
}

```

I hope that logarithm is also counted as a valid mathematical operation :)

Getting the digits of the BigIntegers powered by this guy. With only `int` or `long` this could be way shorter :/
> 2 votes

# Answer
# PHP, ~~105~~ ~~139~~ ~~136~~ 134 bytes

```
function m($a,$b){$s=$x=$a;for($f=10;$x>9;$x=bcdiv($x,10))$f=bcmul($f,10);for(;$b=bcsub($b,1);)$s=bcadd($s,$a=bcmul($a,$f));return$s;}

```

arbitrary precision needs some room in PHP, but I´ll look if I can shrink this a bit.
> 1 votes

# Answer
## Haskell, 38 bytes

```
n%c|a<-until(>n)(*10)1=n*div(a^c)(a-1)

```

Everyone forgets about `until`!
> 1 votes

# Answer
# Python, 65 bytes

```
f=lambda x,n,p=1:p<=x and f(x,n,p*10)or n and f(x,n-1,p)*p+x or 0

```

Ideone it!

First recursion to find the power, second recursion to complete the "concatenation".
> 0 votes

# Answer
# Pyth, 7 bytes

```
i*jQTET

```

Test suite.

Convert to digit list, repeat for that many times, then convert to number.

```
i*jQTET  Q: first input, E: second input
  jQT    convert Q to base T (10) as a digit list
 *   E   repeat for E many times
i     T  convert from digit list to number

```
> 0 votes

# Answer
## JavaScript (ES7), 43 bytes

```
f=(a,b,c=1)=>c>a?(c**b-1)/~-c*a:f(a,b,c*10)

```

Works up to `f(9000,4)`. (Looks like I rediscovered @xnor's formula.) 56-byte ES6 version or 52-byte ES6 version with an even smaller range:

```
f=(a,b,c=0,d=0)=>c<a?f(a,b,c*10+9,d*(b='1e'+b)+--b):d/c*a
f=(a,b,c=1,d=1)=>c>a?~-d/~-c*a:f(a,b,c*10,d*='1e'+b)

```
> 0 votes

# Answer
# Jelly, 3 bytes

```
DẋḌ

```

Try it online!

```
DẋḌ  Main chain, argument: x,y
D    Convert x to list of digits
 ẋ   repeat y times
  Ḍ  Convert back to number

```
> 0 votes

# Answer
## Common Lisp, 73 bytes

```
(lambda(a b)(loop for x below b sum(*(expt 10(*(ceiling(log a 10))x))a)))

```
> -1 votes

# Answer
# k, 20 bytes

Same idea as **Pyth** solution.

Only supports up to 64 bit signed int range.

```
{10/:(y*#d)#d:10\:x}

```

Example

```
k){10/:(y*#d)#d:10\:x}[103;2]
103103

```
> -1 votes

---
Tags: code-golf, math, restricted-source
---