Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#R, (削除) 96 bytes (削除ここまで) 98 bytes -20% -> 78.4

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

#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

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
added 295 characters in body
Source Link
plannapus
  • 9k
  • 23
  • 48

#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 do so I eventually use the regexavoid using 1円 meaning I can't havein the bonusregex I supposeadded an empty group so that I can use 2円.

Usage:

> library(maps);data(us.cities);cat(gsub("()( \\w+)$",",\1円"\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

#R, 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.

Usage:

> library(maps);data(us.cities);cat(gsub("( \\w+)$",",\1円",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

#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
added 10 characters in body
Source Link
plannapus
  • 9k
  • 23
  • 48

#R, 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.

Usage:

> library(maps);data(us.cities);cat(gsub("( \\w+)$",",\1円",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

#R, 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.

Usage:

> library(maps);data(us.cities);cat(gsub("( \\w+)$",",\1円",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

#R, 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.

Usage:

> library(maps);data(us.cities);cat(gsub("( \\w+)$",",\1円",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
Source Link
plannapus
  • 9k
  • 23
  • 48
Loading

AltStyle によって変換されたページ (->オリジナル) /