Drucken Sie die Hauptstädte ohne die Hauptstädte

28

Whoa, whoa, whoa ... hör auf, dein Programm zu tippen. Nein, ich meine nicht "Drucken ABC...". Ich spreche von den Hauptstädten der Vereinigten Staaten.

Drucken Sie insbesondere alle in der folgenden Liste aufgeführten Stadt- / Bundeslandkombinationen aus

  • In irgendeiner Reihenfolge
  • mit Ihrer Wahl der Begrenzer (zB Baton Rouge`LA_Indianapolis`IN_...ist akzeptabel), solange es eindeutig ist, welche Wörter Städte, welche Bundesstaaten und welche Einträge unterschiedlich sind
  • ohne irgendetwas ABCDEFGHIJKLMNOPQRSTUVWXYZin Ihrem Quellcode zu verwenden

Die Ausgabe sollte auf STDOUT oder gleichwertig erfolgen.

BEARBEITEN - Whoops!

<edit>
Während die Liste aus dem Speicher der Eingabe bis (dank der Animaniacs, wie unten beschrieben), I Washington, DC offenbar vernachlässigt, was nicht ist eine Landeshauptstadt, sondern ist in dem Lied, und wird manchmal in „Listen der Hauptstädte“ enthalten ( wie die Mathematica- Antwort unten). Ich hatte vor, diese Stadt in diese Liste aufzunehmen, habe sie aber irgendwie verpasst. Als Ergebnis Antworten , die nicht bestraft werden , dass die Stadt haben nicht, und Antworten , die Sie , dass die Stadt haben , werden nicht bestraft werden, auch nicht . Im Wesentlichen liegt es an Ihnen, ob Sie Washington, DCin Ihrer Ausgabe enthalten sind oder nicht. Tut mir leid, Leute!
</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

(h / t an Animaniacs für die Liste der Hauptstädte)

Nehmen Sie einen Bonus von -20%, wenn Ihre Einreichung nicht explizit die Zahlen 65bis 90oder die Zahl 1im Code enthält. Das Generieren dieser Zahlen (z. B. a=5*13oder a="123"[0]oder a=64;a++dergleichen) ist im Rahmen dieses Bonus erlaubt, das explizite Vorhandensein dieser Zahlen (z. B. a=65oder a="1 23 456"[0]) nicht.

Bestenliste

AdmBorkBork
quelle
12
Diese Herausforderung wurde gemacht für Mathematica.
Skyler
1
@Skyler ist in Mathematica nicht einfach, wenn keine Großbuchstaben verwendet werden!
Ist eine funktionale Rückgabe eine gültige Ausgabeform (zum Beispiel für JS)?
Mwr247,
Zählt die Verwendung des Variablennamens $ 1 als Vorkommen der Zahl 1?
plasticinsect
@ Mwr247 alert(...)ist traditionell das JS-Äquivalent von STDOUT.
AdmBorkBork

Antworten:

8

R, 96 Bytes 98 Bytes -20% -> 78,4

Danke an @plasticinsect für den Bonus!

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

Vorheriger Code bei 96 Bytes:

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

Aus dem Paket mapswird ein Datensatz mit US-Städten geladen. Spalte capitalenthält ein, 2wenn es eine Landeshauptstadt ist. Die Namen der Städte werden namein der Spalte "City StateAbbreviation" (dh Albany NY) angegeben, daher muss vor der Ausgabe ein explizites Trennzeichen hinzugefügt werden. Um dies zu tun, benutze ich irgendwann den regulären Ausdruck, \1was bedeutet, dass ich den Bonus, den ich nehme, nicht haben kann. Um die Verwendung \1im regulären Ausdruck zu vermeiden, habe ich eine leere Gruppe hinzugefügt, damit ich sie verwenden kann \2.

Verwendung:

> 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
Plannapus
quelle
Wenn Sie am Anfang Ihres regulären Ausdrucks eine leere Erfassungsgruppe hinzufügen, können Sie \ 2 anstelle von \ 1 verwenden. Es würde Sie zwei Bytes kosten, aber Sie gewinnen den Bonus.
plasticinsect
@plasticinsect Danke! Daran hätte ich nicht gedacht.
Plannapus
Großer Gebrauch von eingebautem. Drei Dinge: 1. Sie können die neue Zeile innerhalb des Codes anstatt \nfür 1 Byte >0anstelle von `` == 2` eingeben und ich glaube auch nicht, dass Sie es brauchen data(us.cities), auf meinem Computer wird es geladen, wenn Sie das Paket laden. Versuch es!
JayCe
1
Noch kürzer durch Umbenennen der Daten.
JayCe
27

Mathematica, 168 153 149 Bytes - 20% = 119,2 Bytes

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

Obligatorisch, aber ich wusste nicht , dass jedes Zeichen durch ersetzt werden kann \.xxoder \:xxxxmit dem entsprechenden Hex - Code.

Bearbeiten: 4 weitere Zeichen werden durch Threadeine reine Funktion ersetzt.

Ausgabe:

{{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}}

quelle
Ich glaube auch nicht, dass die verbotenen Nummern verwendet werden
Sehr klarer Weg, um Kapital zu schlagen. Die Verwendung von Hex-Codes war mir nicht bekannt. Wie bringen Sie sie dazu, nicht sofort als Großbuchstaben im Code angezeigt zu werden?
DavidC
2
Dadurch wird möglicherweise Code gespart, auch nachdem Sie die Kappen ersetzt haben:EntityValue[EntityList[EntityClass["AdministrativeDivision", "AllUSStatesPlusDC"]], {"CapitalName","StateAbbreviation"}]
DavidC,
@ DavidCarraher Zu viele Hauptstädte in AllUSStatesPlusDCIch fürchte!
Ja. Ich verstehe was du meinst.
DavidC
8

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}/

Der Code ist 390 Bytes lang und qualifiziert sich für den 20% Bonus .

Beachten Sie, dass der Code mit nicht druckbaren Zeichen durchsetzt ist. Probieren Sie es online im CJam-Interpreter aus .

Idee

Wir müssen die Ausgabe irgendwie codieren, ohne irgendwo im Code Großbuchstaben oder die Zahlen 1 und 65 bis 90 zu verwenden.

Wir beginnen mit dem Umschreiben der gewünschten Ausgabe als

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

Indem `wir das Zeichen von allen Zeichen dieser Zeichenfolge subtrahieren , erhalten wir ein Array, das Ganzzahlen von 0 bis 26 enthält. Wir können dieses Array von Basis 27 zu Basis 229 konvertieren und so ein Array von Ganzzahlen von 0 bis 228 erhalten.

Wenn wir zu jeder Zahl der Basis 229 91 addieren und das Ergebnismodul 256 nehmen, ordnen wir den Bereich [0,…, 164] zu [91,… 255] und den Bereich [165,…, 228] zu [0, 63] . Dadurch bleiben die Zeichen mit Codepunkten von 64 ( @) bis 90 ( Z) unbenutzt.

Die zu codierende Zeichenfolge stimmt nicht mit der in der Frage angegebenen Beispielausgabe überein. Ich habe mehrere Permutationen ausprobiert, bis ich eine gefunden habe, die keine Nullbytes, Zeilenvorschübe, Zeilenumbrüche oder Leerzeichen (problematisch mit dem Online-Interpreter) und keine doppelten Anführungszeichen (Escape-Zeichen erforderlich) enthält.

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#
Dennis
quelle
Wie funktioniert das? Wie werden die Hauptstädte ohne Kodierung erzeugt?
@ MathiasFoster Ich habe meine Antwort aktualisiert.
Dennis
7

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

Meine erste Version war ungültig, weil sie mit \ U in Großbuchstaben konvertiert wurde. Dieser verwendet \ u für jeden Buchstaben der Staatsabkürzung. Ich musste auch eine Dummy-Erfassungsgruppe hinzufügen, um die Verwendung von $ 1 zu vermeiden.

Edit: Ich konnte 8 Bytes mit uc () mit dem e Flag abschneiden. (Danke, Dom Hastings.)

plasticinsect
quelle
7

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 ist auch besonders schwierig, wenn man die langen Funktionsnamen und das Kamelgehäuse berücksichtigt. Das Aufteilen der Zustände sparte eine Menge Trennzeichen und erleichterte die Arbeit mit allen.

@ mbomb007 nichts in der Post aus einem Grund großgeschrieben;)

Mwr247
quelle
5

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);}

Ich habe die Schleife ein wenig geändert, damit sie mit Nicht-C99-Compilern kompiliert werden kann. Online Version


quelle
Schließlich ist der Kommaoperator nützlich.
5

Javascript (es6) 516 (645-20%) 532 (664-20%)

Testen Sie das folgende Snippet in einem aktuellen Browser: Es wird nur die Funktion es6 verwendet 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']()))

edc65
quelle
sehr schlau! hatte nicht daran gedacht, aus irgendeinem Grund zu ersetzen ...
Mwr247
5

Funktion , 5045 - 20% = 4036 Bytes

Dieser Code enthält nur eine Zahl und liegt nicht im Bereich von 65 bis 90. Es handelt sich auch nicht um die Zahl 1. Tatsächlich handelt es sich bei dieser Zahl um 4187 Dezimalstellen, die sauber in die Primzahlen 79 × 53 zerlegt werden.

Wie immer erhalten Sie ein besseres Rendering, indem Sie es $('pre').css('line-height',1);in Ihrer Browserkonsole ausführen .

╔═══════════════════════════════════════════════════════════════════════════════╗
║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! Diese Antwort ist codegolf.SE Beitrag # 61000!

Timwi
quelle
1
Nicht abgefangene TypeError: $ (...). CSS ist keine Funktion (...)
Dkudriavtsev
5

x86-Maschinencode, 764 Byte

612 wenn Bonus vergeben

Völlig in sich geschlossenes Programm. Verlässt sich nur darauf, dass (a) Bios int 0x10 verfügbar ist, um jedes Zeichen zu drucken, und (b) DS, ES, SP und SS initialisiert werden, bevor das Programm aufgerufen wird, DOS tut dies. (Und auch DOS-Box) Andernfalls stützt sich der Code auf nichts. Das absolute Minimum ohne jegliche Abhängigkeiten, mit Ausnahme des BIOS-Roms, wären etwa 2 Diskettensektoren mit jeweils 512 Bytes.

Es scheint keine der Standard-Schlupflöcher auszunutzen, obwohl einige Bytes des Programms 01 sind, sind dies keine Zahlen in der Quelle. Da ich jedoch den Binärcode als meine Lösung übergeben möchte, stelle ich mir vor, dass die 01-Bytes nicht zulässig sind.

Hex-Editor-Ansicht der Binärdatei:

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.

'Ungolfed' Version (Quelle - 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

Ausgabe:

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
Enhzflep
quelle
5

Python 3, 1416 793 785 779 771 755 734 Zeichen - 20% = 587,2

Keine algorithmische Klugheit hier, ich habe nur die erforderliche Ausgabe genommen, sortiert (dies lässt Zlib einen besseren Job machen), komprimiert (mit zopfli --deflate), das Ergebnis mit Base64 codiert und dann die Codierung geändert, um Großbuchstaben zu vermeiden.

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'))

Nicht golfen:

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'))

Es ist wahrscheinlich mehr herauszuholen, insbesondere wenn Sie das Argument translate()kompakter ausdrücken können. Beachten Sie, dass die Interpunktion dort sorgfältig ausgewählt wird, um die eigene Interpunktion von base64 (+ / =) und alles zu vermeiden, was in einem String-Literal ein Backwhacking erfordern würde.

Unterhaltsame Tatsache: Die Module bz2 und lzma schneiden bei dieser Eingabe schlechter ab als 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
zwol
quelle
1
Zumindest ist es schön und lesbar. ;-)
AdmBorkBork
Sie können das import zlib,base6am Anfang entfernen und DATA.translate(tr).decode('base64').decode('zlib').decode('utf-8')warum brauchen Sie das decode('utf-8')überhaupt?
pppery
@ppperry Leider funktioniert Ihr Vorschlag nur in Python 2; und in Python 2 .translatefunktioniert das anders und { x:y for x,y in ... }ist nicht verfügbar. Ohne die .decode('u8')in Python 3 ist die Ausgabe die repr () der Byte-Zeichenfolge, die weit genug von der angeforderten Ausgabe entfernt ist, dass ich nicht dachte, es sollte zählen.
20.
4

Pyth, (631 & ndash; 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"","

Ausgabe:

['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']

Der zweite Parameter für rwechselt zwischen 5 ( capwords()) und 1 ( upper())

Fabian Schmengler
quelle
Hoppla, falscher Variablenname. Zum Glück können sie in Kleinbuchstaben geändert werdenk
Fabian Schmengler
3

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()
 }
Bevo
quelle
@TessellatingHeckler Danke, aber ich kann keine wörtliche 1 verwenden, ohne den Bonus zu verlieren. Und auch danke für die früheren Vorschläge, die den Eintrag 749 599.2 ermöglichten.
Bevo
@TessellatingHeckler Ich habe Ihre Idee benutzt, um $ _ für das letzte Segment der Zeichenfolge zu verwenden - danke!
Bevo
2

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)

Vielen Dank an Sp3000 , der mich daran erinnert hat, dass ich pGroßbuchstaben in den Code einfügen kann!

Erläuterung

Das Bit der ersten Zeile vor dem "setzt nichts anderes als einen R(Stapel drehen) anstelle von rund ersetzt dann alle Instanzen von omit Oin der zweiten Zeile.

Danach ist es die Liste der Großbuchstaben ohne Zeilenumbruch und alle Kleinbuchstaben, die Minkolang in umgekehrter Reihenfolge auf den Stapel schiebt. Am 01wEnde befindet sich ein "Wurmloch" am Anfang der zweiten Zeile. Alle Großbuchstaben werden durch Subtrahieren von 32 vom Kleinbuchstaben ausgegeben, weshalb 48*-viermal angezeigt wird.

48*-Ogibt aus Bund (beginnt dann eine while-Schleife. Die Oberseite des Stapels wird gegen geprüft ,. Wenn es nicht ist ,, dann O)gibt das Zeichen und springt zum Anfang der Schleife zurück. Wenn der oberste Stapel ist , , dann springt der Programmzähler O)wegen über2& eines bedingten Trampolins über, das zwei Felder überspringt.

Jetzt springe ich, wenn ich auf einen treffe, ,weil ich weiß, dass die nächsten sechs Zeichen sind , AB\nC, was der Rest der Schleife tut. Es wird geprüft, ob der Stapel in der Mitte leer ist (nach dem ABgedruckt wird, bevor \nC): d?. Wenn dies der Fall ist, wird das bedingte Trampolin nicht genommen, und das Programm wird beendet, wenn Sie die Taste drücken .. Andernfalls wird es übersprungen und die Schleife fortgesetzt.

El'endia Starman
quelle
2

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)).'_';

Ergebnis

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)
         )
         . '_';

Ich habe verschiedene Möglichkeiten ausprobiert, um die Zeichenfolge zu komprimieren, aber am Ende waren alle Lösungen länger als dieser einfache Ansatz.

insertusernamehere
quelle
2

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))])

Gibt das Ergebnis als Python-Liste mit Python-Tupeln aus. Sie sind auch in Anführungszeichen eingeschlossen. Dies ist definitiv für den Bonus qualifiziert, da die einzige Zahl im Code 2 ist.

Ausgabe:

[('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')]

Ich hoffe, dass dies innerhalb der akzeptablen Grenzen der Formatierung liegt.

bkul
quelle
2

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])}

Inspiriert von Edc65's cleverem Zusammenspiel von Staat und Stadt!

K. Klassen
quelle
Das tut mir leid. Der Code sollte sich jetzt für den Bonus qualifizieren. Ich denke, ich hätte den Bonusabschnitt genauer lesen sollen.
K. Klassen
2

PowerShell, 627 -20% = 502 Byte

[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()})

Welches ist dieses Muster:

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

Großschreibung des einzelnen Buchstabens nach einer Wortgrenze oder der Doppelbuchstaben vor einem Doppelpunkt. Der "$args,"[3]Befehl wählt entweder das Komma bei einem Doppelbuchstaben-Statuscode aus oder wählt über und gibt null zurück und fügt die Statustrennzeichen hinzu, wobei ~ 50 in Trennzeichen aus der Codezeile gespeichert werden.

TessellatingHeckler
quelle
1

Rubin (925 × 80%) = 740 Bytes

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

Oof, das war schwer. Dies ist eine Zlib-komprimierte Zeichenfolge in hexadezimal codierten Bytes, die dann dekomprimiert und vom Scan-Regex in ein Array von Zeichenfolgen umgewandelt wird. Anschließend wird jede Zeichenfolge in eine Dezimalzahl und anschließend in ein Zeichen konvertiert Zeichenfolge. Ich werde später möglicherweise eine bessere Version veröffentlichen, die eine geänderte Base64-Codierung verwendet.

Obwohl die codierte Zeichenfolge einige Instanzen von 65-90 oder Einsen aufweisen kann, zähle ich diese nicht, da die Zeichenfolge eine große hexadezimale Zahl ist. Somit ist dies für den 20% Bonus qualifiziert.

dkudriavtsev
quelle
1

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)]

Die unten stehende Version (675 Bytes) enthält Informationen ''.join([w.capitalize()for w in t[n][2:].split()]), die ich gerade entdeckt habe .title()und durch eine anonyme Funktion ersetzen kann. In beiden Antworten sind die staatlichen Abkürzungen an die Hauptstädte angehängt.

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)]
Daniel
quelle
-1

x86-Maschinencode - 585 Bytes, 468 mit Bonus

Enttäuscht darüber, wie groß mein letzter Eintrag war, beschloss ich, diesmal etwas ganz anderes zu probieren. Malen aufinsertusernamehereDa ich mich die Idee stützte, die Namen der Städte von den Namen der Bundesstaaten zu trennen, um unnötige Logik und unnötige Terminatoren zu vermeiden, dachte ich immer noch, ich müsste das Programm kleiner machen können, als es die rohen Zeichenfolgen sind. UPX würde mir nicht helfen zu schummeln und mich beschweren, dass das Programm bereits zu klein war. Beim Komprimieren habe ich versucht, die 662-Byte-Textausgabe mit WinRar zu komprimieren, habe aber immer noch nur 543 Byte - und das ohne irgendetwas, mit dem ich es dekomprimieren könnte. Es schien immer noch viel zu groß zu sein, da es nur das Ergebnis ohne Code war.

Dann wurde mir klar - ich verwende nur 26 Zeichen für die Buchstaben und 2 für die Leerzeichen und die Kommas. Hmm, das passt in 32, das braucht nur 5 Bits. Also habe ich ein schnelles Javascript-Programm geschrieben, um die Zeichenfolgen zu codieren. Dabei wurden z 0-25 und Leerzeichen und Komma 26 und 27 zugewiesen. Um die Dinge einfach zu halten, wird jedes Zeichen in 5 Bits codiert, unabhängig davon, ob es so viele benötigt oder nicht. Von da an habe ich einfach alle Teile zusammengeklebt und sie wieder in byte-große Stücke zerlegt. Dies erlaubte mir, die 563 Bytes von Strings in 353 Bytes zu packen - eine Einsparung von 37,5% oder 210 Bytes. Ich habe es nicht ganz geschafft, das Programm und die Daten auf den gleichen Platz zu bringen wie die entpackten Daten, aber ich bin nah genug dran, um glücklich zu sein.

Hxd-Ansicht der Binärdatei:

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.

Quellcode:

[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
Enhzflep
quelle
2
Ich sehe viele Großbuchstaben in Ihrem Dump.
edc65
Ugggh. Natürlich tue ich das jetzt auch, wo ich hinschaue. Ich war so besessen davon, sie zu generieren, dass ich die Tatsache übersehen habe, dass ich versehentlich einige erstellt habe. Die ersten 232 Bytes sind Code für die Restdaten. Ich sehe, ich habe Mützen in jedem. Ich bin vielleicht einfach gesunken und habe keine Chance, es zu reparieren. :( Ich werde einige selbst-modifizierenden Code später untersuchen, obwohl die Offset - Tabelle werde ich brauchen keine Gewinne verbrauchen gemacht: Seufzer: -. Oh well.Thanks für den Hinweis , obwohl es aus, ich schätze es.
enhzflep