Take a ride on the Reading, If you pass Go, collect $200

39

4

Monopoly Board

For this code-golf challenge we will be building the board game Monopoly.

Rules:

  • Take no input.
  • Output a 11x11 board where each ASCII character forming the board is the first letter of each space of the U.S. version of the Monopoly board.
  • The characters must be separated by spaces.
  • Go should start in the bottom right.

The exact string to produce is

F K C I I B A V W M G 
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G 

Note that from bottom right to bottom left the squares are as follows:

G --> Go
M --> Mediterranean Avenue
C --> Community Chest
B --> Baltic Avenue
I --> Income Tax
...
J --> Jail

Edit Wow! you guys sure liked this one! :)

jacksonecac

Posted 2016-10-19T12:11:31.433

Reputation: 2 584

7I don't mean to be a stickler but... how does one pass Go while advancing to Boardwalk? – Sp3000 – 2016-10-19T12:27:36.027

4If you are on boardwalk :) – jacksonecac – 2016-10-19T12:28:07.943

8Which you can't get a chance card if you are on boardwalk :( – jacksonecac – 2016-10-19T12:28:54.983

27I failed you all – jacksonecac – 2016-10-19T12:29:06.843

Is the trailing space on the bottom-right needed? – Erik the Outgolfer – 2016-10-19T12:34:25.253

There's also one on the first row. I assumed these were editing mistakes. – Martin Ender – 2016-10-19T12:37:25.253

@jacksonecac, I have an idea to extend this puzzle in another question, your input would be great!

– James Webster – 2016-10-19T14:54:35.940

3Are trailing spaces allowed? – Adnan – 2016-10-19T16:46:55.170

@jacksonecac Of course you can get a chance card on boardwalk. If you don't cheat at monopoly, you're not playing monopoly right :D – Pierre Arlaud – 2016-10-20T11:59:01.540

That's why I am always the banker – jacksonecac – 2016-10-20T11:59:50.860

1@Sp3000 While we are being sticklers, how does one NOT pass go while advancing to Reading? – Kevin – 2016-10-20T19:36:04.847

1This must be what American monopoly looks like. Huh, weird. – ArtOfCode – 2016-10-20T20:44:06.037

@jacksonecac No, this is what Monopoly looks like ;)

– ArtOfCode – 2016-10-21T11:13:16.650

@ArtOfCode It is identical. except for those random images on the properties. – jacksonecac – 2016-10-21T11:14:41.160

1@jacksonecac Property names. We get Fleet Street, Old Kent Road, Mayfair, etc, over here. – ArtOfCode – 2016-10-21T12:29:36.380

@Kevin I think this one is legit.. If you are on the community chest between Go and Reading railroad, you could get that card. (If that card is indeed a community chest and not a chance card) – jacksonecac – 2016-10-21T18:26:46.620

1http://thesaltcollective.org/wp-content/uploads/2014/04/Chance-Take-a-Ride-on-the-Reading-604x270.png Failed again! I am the WORST! I suppose this stickler is for Hasbro this time, passing the buck. – jacksonecac – 2016-10-21T18:28:13.753

Answers

36

Retina, 74 bytes


FKCIIBAVWMGN_PT_NC_CS_PP_SV_CS_PE_LS_BJCVCORIBCMG
S_`(._.)
_
9$*
\B

1

The third to last and last lines should contain a single space.

Try it online!

Explanation


FKCIIBAVWMGN_PT_NC_CS_PP_SV_CS_PE_LS_BJCVCORIBCMG

This replaces the (empty) input with the string on the second line.

S_`(._.)

This is split stage, which splits the string around matches of the regex (._.) (that is, any three characters with a _ in the middle). The reason we put the whole regex in a group is that split stages also return the results of capturing groups. E.g. splitting abcd around bc gives [a, d], but splitting it around b(c) gives [a, c, d]. This way we get all the ._. parts on separate lines but also the 11-character parts at the beginning and end. We use the _ option to omit empty results between the individual ._. matches. The result would be this:

FKCIIBAVWMG
N_P
T_N
C_C
S_P
P_S
V_C
S_P
E_L
S_B
JCVCORIBCMG

Next we process the underscores:

_
9$*

This replaces each underscore with nine 1s. The reason we use 1s here instead of spaces immediately is that it makes it easier to insert the padding spaces next.

\B

Remember that there's a space on the second line. This inserts a space in every position that isn't a word boundary, i.e. everywhere except at the beginning and end of the lines.

1

And finally, we replace all those 1s with spaces as well.

Martin Ender

Posted 2016-10-19T12:11:31.433

Reputation: 184 808

1Nice Job! That was fast! – jacksonecac – 2016-10-19T12:27:51.510

39+1 for (._.). – Destructible Lemon – 2016-10-19T12:55:10.987

^ was just about to say that ahha – jazzboy – 2016-10-19T23:18:53.870

25

Jelly, 44 bytes

“£ċ9NɲT⁴MỵƇñdMỊḞ*µ7Sʂɓ¢Ż}ạ¥ċwÞ’ḃ23ṣ4ịØAz⁶ṙ1G

Try it online!

Idea

If we remove every second column and transpose rows with columns, we get the following board.

FNTCSPVSESJ
K         C
C         V
I         C
I         O
B         R
A         I
V         B
W         C
M         M
GPNCPSCPLBG

Now, we can rotate each column one unit to the right, moving all remaining spaces to the right.

JFNTCSPVSES
KC         
CV         
IC         
IO         
BR         
AI         
VB         
WC         
MM         
GGPNCPSCPLB

Then, we remove the remaining spaces and replace linefeeds with the letter D.

JFNTCSPVSESDCKDVCDCIDOIDRBDIADBVDCWDMMDGGPNCPSCPLB

Now, we replace each letter with its 1-based index in the alphabet.

10  6 14 20  3 19 16 22 19  5 19  4  3 11  4 22  3  4  3  9  4 15  9  4 18
 2  4  9  1  4  2 22  4  3 23  4 13 13  4  7  7 16 14  3 16 19  3 16 12  2

Then, we convert this digit array from bijective base 23 to integer.

54580410997367796180315467139871590480817875551696951051609467717521

Now, we convert this integer to bijective base 250.

  2 232  57  78 163  84 132  77 228 144  27 100  77 176 195
 42   9  55  83 167 155   1 210 125 211   4 232 119  20

Finally, we use these digits to index into Jelly's code page.

£ċ9NɲT⁴MỵƇñdMỊḞ*µ7Sʂɓ¢Ż}ạ¥ċwÞ

This is the encoded data we'll include in the program (29 bytes). To produce the desired output, we just have to reverse the steps above.

Code

“£ċ9NɲT⁴MỵƇñdMỊḞ*µ7Sʂɓ¢Ż}ạ¥ċwÞ’ḃ23ṣ4ịØAz⁶ṙ1G  Main link. No arguments.

“£ċ9NɲT⁴MỵƇñdMỊḞ*µ7Sʂɓ¢Ż}ạ¥ċwÞ’               Convert the string from bijective
                                              base 250 (using the indices in
                                              Jelly's code page) to integer.
                               ḃ23            Convert that integer to bijective
                                              base 23.
                                  ṣ4          Split the resulting array at
                                              occurrences of 4.
                                    ịØA       Replace the remaining digits in the
                                              resulting 2D array with the
                                              corresponding uppercase letters.
                                       z⁶     Zip/transpose rows and columns,
                                              padding shorter rows with spaces.
                                         ṙ1   Rotate the rows one unit down.
                                           G  Grid; join rows by spaces, columns
                                              by linefeeds.

Dennis

Posted 2016-10-19T12:11:31.433

Reputation: 196 637

5Thanks for the detailed explanation. It's always interesting to see the process behind answers to code golf questions. :) – XtraSimplicity – 2016-10-19T19:53:11.267

11Code Golf - where it's perfectly normal to see a number in base 250 and base 23. – corsiKa – 2016-10-19T22:47:18.820

Nice compression technique. Why is transposing necessary? – ETHproductions – 2016-10-20T01:53:26.220

@ETHproductions Jelly doesn't have a padding atom, so I can either manually pad all rows with spaces to the same length or use the dyadic zip (z) with a filler. – Dennis – 2016-10-20T01:55:28.867

16

05AB1E, 48 47 bytes

Thanks to Emigna for saving a byte!

•(K·;“…¬È¦z"9äuŸé;TÞîÕs‡ÓÐV9XÒt\<•33B¾9ð×:S11ô»

Explanation:

First some compression. •(K·;“…¬È¦z"9äuŸé;TÞîÕs‡ÓÐV9XÒt\<• is a compressed version of the following number:

120860198958186421497710412212513392855208073968557051584380118734764403017

After that, this is converted to base 33, which results into the following string:

FKCIIBAVWMGN0PT0NC0CS0PP0SV0CS0PE0LS0BJCVCORIBCMG

The zeroes are replaced by 9 spaces, using the following code ¾9ð×:. After that, we Split the string into characters and slice them into pieces of 11 elements (done with 11ô). We get the following 2-dimensional array:

[['F', 'K', 'C', 'I', 'I', 'B', 'A', 'V', 'W', 'M', 'G'], 
 ['N', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P'], 
 ['T', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'N'], 
 ['C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'C'], 
 ['S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P'], 
 ['P', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'S'], 
 ['V', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'C'], 
 ['S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P'], 
 ['E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'L'], 
 ['S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B'], 
 ['J', 'C', 'V', 'C', 'O', 'R', 'I', 'B', 'C', 'M', 'G']]

We gridify this array with » and output it implicitly.

Uses the CP-1252 encoding. Try it online!

Adnan

Posted 2016-10-19T12:11:31.433

Reputation: 41 965

3Compressing with 0 instead of D saves a byte •(K·;“…¬È¦z"9äuŸé;TÞîÕs‡ÓÐV9XÒt\<•33B¾9ð×:S11ô» – Emigna – 2016-10-19T13:41:51.210

@Emigna Ah, that's clever! Thanks :). – Adnan – 2016-10-19T14:58:07.087

12

Python 2, 89 bytes

l='%s '*11+'\n'
print(l+'%s%20s\n'*9+l)%tuple("FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG")

Creates the template

? ? ? ? ? ? ? ? ? ? ? 
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
? ? ? ? ? ? ? ? ? ? ? 

to substitute in letters via string formatting. The template uses two types of lines:

  • The outer line l of 11 copies of letter-plus-space, then a newline. It's also used for the first and last line. It has a trailing space.
  • The inner line of a character, then a character preceded by 19 characters of padding spaces, then a newline. It's copied 9 times for the center lines.

Python 3.5 can save a byte with tuple unpacking (*'...',).

xnor

Posted 2016-10-19T12:11:31.433

Reputation: 115 687

1Switching to Python 3.5 should save a byte. – Dennis – 2016-10-20T03:54:29.683

9

PowerShell v2+, 131 123 114 110 99 bytes

'F K C I I B A V W M G
N0P
T0N
C0C
S0P
P0S
V0C
S0P
E0L
S0B
J C V C O R I B C M G'-replace0,(" "*19)

This is just a literal string with newlines placed on the pipeline, with a little -replace at the end to turn the 0 into 19 spaces. The first and last lines are just verbatim. With only 10 spaces and little repetition otherwise, there wasn't enough room to golf them. This string is left on the pipeline, and output via implicit Write-Output happens at program completion.

PS C:\Tools\Scripts\golfing> .\take-a-ride-on-reading.ps1
F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G

AdmBorkBork

Posted 2016-10-19T12:11:31.433

Reputation: 41 581

9

Javascript ES6 REPL, 105 102 101 bytes

Not much interesting happening here. Paste in the console to see the desired results

Saved 3 bytes thanks to @Arnauld
Saved 1 more byte thanks to @Neil

`FKCIIBAVWMG
N P
T N
C C
S P
P S
V C
S P
E L
S B
JCVCORIBCMG`.replace(/.( ?)/g,`$& `+`$1`.repeat(17))

a.innerHTML = 

`FKCIIBAVWMG
N P
T N
C C
S P
P S
V C
S P
E L
S B
JCVCORIBCMG`.replace(/.( ?)/g,`$& `+`$1`.repeat(17))
<pre id=a>

Bassdrop Cumberwubwubwub

Posted 2016-10-19T12:11:31.433

Reputation: 5 707

I don't think REPL is allowed. – NoOneIsHere – 2016-10-19T14:38:08.450

@NoOneIsHere http://meta.codegolf.stackexchange.com/a/7844/8478

– Martin Ender – 2016-10-19T17:19:58.873

1I managed to shave off another byte. Replace the 1s with spaces and use this regexp instead: .replace(/.( ?)/g,\$& `+`$1`.repeat(17))` – Neil – 2016-10-19T21:17:03.480

A different way to shave off another byte is to replace the 1s with spaces and use this function instead: a=>a-1?a.repeat(18):a+' ' – ETHproductions – 2016-10-20T01:56:50.093

@Neil thanks, love your approach! – Bassdrop Cumberwubwubwub – 2016-10-21T08:25:16.707

7

///, 100 98 bytes

/s/    //p/ssss   //q/pC
SpP
//!/ C /F K!I I B A V W M G 
NpP
TpN
CqPpS
VqEpL
SpB
J!V!O R I B!M G 

Try it online!

For some mysterious reason, there seem to be trailing spaces after the Gs. Without them, my code would have been 96 bytes.

Thanks to 42545 (ETHproductions) and 56258 (daHugLenny) for reducing 1 byte each!

Erik the Outgolfer

Posted 2016-10-19T12:11:31.433

Reputation: 38 134

@ETHproductions Wrong link maybe? I can't save any byte like that. – Erik the Outgolfer – 2016-10-19T12:46:21.817

Isn't this 98 bytes if you remove the space after the Gs on the first and last line? – Emigna – 2016-10-19T13:46:33.030

1

@Emigna Whole discussion about the extra spaces.

– Erik the Outgolfer – 2016-10-19T13:47:34.977

1@Emigna I know, but the exact output contains them, so I won't remove them. – Erik the Outgolfer – 2016-10-19T13:51:21.010

My bad, try this.

– ETHproductions – 2016-10-19T14:23:28.637

You can save 1 byte by adding a C replacement

– acrolith – 2016-10-19T14:24:08.443

@ETHproductions Updated my code. – Erik the Outgolfer – 2016-10-19T14:33:31.203

@daHugLenny Updated my code. – Erik the Outgolfer – 2016-10-19T14:33:39.933

6

Turtlèd, 72 bytes

"K C I I B A V W M G">"GPNCPSCPLBG">"G M C B I R O C V C J">"JSESVPSCTNF

Try it online

> rotates turtle, "foo" writes strings on grid. last " was elidable

Destructible Lemon

Posted 2016-10-19T12:11:31.433

Reputation: 5 908

5

V, 75, 62, 59 bytes

iFKCIIBAVWMG
NPTNCCSPPSVCSPELSB
JCVCORIBCMG-ò9á lli
òÍ./& 

Try it online!

Since this codel contains non-ASCII characters, here is a hexdump:

0000000: 6946 4b43 4949 4241 5657 4d47 0a4e 5054  iFKCIIBAVWMG.NPT
0000010: 4e43 4353 5050 5356 4353 5045 4c53 420a  NCCSPPSVCSPELSB.
0000020: 4a43 5643 4f52 4942 434d 471b 2df2 39e1  JCVCORIBCMG.-.9.
0000030: 206c 6c69 0af2 cd2e 2f26 20               lli..../& 

Explanation. First, we enter the following text:

FKCIIBAVWMG
NPTNCCSPPSVCSPELSB
JCVCORIBCMG

Then, we <esc> back to normal mode. At this point, the cursor is on the third line on the last G. Conveniently, there is a command to put us on the first column of the line right above the cursor. That command is -. Then, once we end up on the second line (on the N), we run the following loop:

ò9á lli
ò

Explanation:

ò           " Recursively:
 9á         "   Append 9 spaces
    ll      "   Move to the right twice. This will fail on the last time because there isn't a space to move into
      i     "   Enter a newline
ò           " End

Now, the buffer looks like this:

FKCIIBAVWMG
N         P
T         N
C         C
S         P
P         S
V         C
S         P
E         L
S         B
JCVCORIBCMG

Now we use a compressed regex to replace each character with that character and a space. That's the Í./& part. This translates to the following vim regex:

:%s/./& /g

Which means:

:%          " On any line
  s/        " Substitute
    ./      " Any character with
      & /   " That same character and a space
         g  " Allow for multiple substitutions on the same line

James

Posted 2016-10-19T12:11:31.433

Reputation: 54 537

4

R, 149 146 bytes

Not so impressive but also not sure how this would be golfed. Exploiting paste somehow is my first guess. Compare to raw text of 241 bytes.

x=strsplit("NTCSPVSESPNCPSCPLB","")[[1]];cat("F K C I I B A V W M G\n");for(i in 1:9)cat(x[i],rep("",18),x[i+9],"\n");cat("J C V C O R I B C M G")

R-fiddle

Billywob

Posted 2016-10-19T12:11:31.433

Reputation: 3 363

4

Perl, 90 bytes

Pretty boring approach, can't think of a better way to reduce... Requires -E at no extra cost. Outputs an additional space at the end of every line. -2 bytes thanks to @Dada!

say"FKCIIBAVWMG
NZP
TZN
CZC
SZP
PZS
VZC
SZP
EZL
SZB
JCVCORIBCMG"=~s/Z/$"x9/ger=~s/./$& /gr

Usage

perl -E 'say"FKCIIBAVWMG
NZP
TZN
CZC
SZP
PZS
VZC
SZP
EZL
SZB
JCVCORIBCMG"=~s/Z/$"x9/ger=~s/./$& /gr'

Dom Hastings

Posted 2016-10-19T12:11:31.433

Reputation: 16 415

2 bytes shorter (but basically the same code as you) : perl -E 'say"FKCIIBAVWMG\nNZP\nTZN\nCZC\nSZP\nPZS\nVZC\nSZP\nEZL\nSZB\nJCVCORIBCMG"=~s/Z/$"x9/ger=~s/./$& /gr'. (Replace \n by literal newlines to get to 90). – Dada – 2016-10-19T15:23:36.123

@Dada Ahhh, much nicer! Thanks! – Dom Hastings – 2016-10-19T15:45:50.507

"much nice" would have been finding a 40 bytes solution, but thanks :D – Dada – 2016-10-19T20:10:10.773

4

Python 2, 108 bytes

Slightly different than the other python answer, using no replaces, only string joins.

print'\n'.join(map(' '.join,['FKCIIBAVWMG']+map((' '*9).join,zip('NTCSPVSES','PNCPSCPLB'))+['JCVCORIBCMG']))

TFeld

Posted 2016-10-19T12:11:31.433

Reputation: 19 246

1I knew zip was the way forward! Had pretty much the same solution down to 118 earlier and was going to golf it this evening. I was missing the map. Guess you beat me to it. +1 – ElPedro – 2016-10-19T17:23:17.277

4

Jolf, 72 bytes

Ζ0ρ,ahtht"111"'.d?=H♣Q♣+."FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"wΖhζ♣

Replace all with \x05, or try it here!

Ζ0ρ,ahtht"111"'.d?=H♣Q♣+."..."wΖhζ♣
Ζ0                                   ζ = 0
   ,ahtht"111"                       a box of width&height 11, with borders "1"
  ρ           '.d                    replace each char in that string with...
                 ?=H♣                 is it a space?
                     Q♣                if so, return two spaces.
                                      otherwise
                        ."..."         get the Nth member of this string
                              wΖhζ      where N = (++ζ) - 1
                       +          ♣      and add a space to the end

This gives the desired string.

Conor O'Brien

Posted 2016-10-19T12:11:31.433

Reputation: 36 228

3

Java 7, 177 165 142 131 bytes

String c(){return"FKCIIBAVWMG\nN_P\nT_N\nC_C\nS_P\nP_S\nV_C\nS_P\nE_L\nS_B\nJCVCORIBCGM".replace("_","         ").replace(""," ");}

-15 bytes thanks to @BassdropCumberwubwubwub.
-11 bytes thanks to @Numberknot.

Ungolfed & test code:

Try it here.

class M{
  static String c(){
    return "FKCIIBAVWMG\nN_P\nT_N\nC_C\nS_P\nP_S\nV_C\nS_P\nE_L\nS_B\nJCVCORIBCGM"
      .replace("_","         ").replace(""," ");
  }

  public static void main(String[] a){
    System.out.print(c());
  }
}

Output:

F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G

Kevin Cruijssen

Posted 2016-10-19T12:11:31.433

Reputation: 67 575

1String c(){String s=" ";return"FKCIIBAVWMG\nN_P\nT_N\nC_C\nS_P\nP_S\nV_C\nS_P\nE_L\nS_B\nJCVCORIBCMG".replace(""," ").replace("_",s);} for 150 (note that stackexchange removes excessive spaces) – Bassdrop Cumberwubwubwub – 2016-10-19T13:29:07.123

@BassdropCumberwubwubwub Umm.. this outputs only 3 spaces between the 'vertical walls', instead of 19.. Here is an ideone of your code.

– Kevin Cruijssen – 2016-10-19T13:34:17.623

Hence my note, there should be more spaces in s but stackexchange removed them. Here's the ideone, now even at 142 bytes

– Bassdrop Cumberwubwubwub – 2016-10-19T13:43:57.683

@BassdropCumberwubwubwub Ah ok. Didn't knew you ment between the s=" ". In that case it's indeed shorter. And.‌​replace(""," ").replace("_",s); can be .replace("_",s).‌​replace(""," "); instead for an additional -8 bytes – Kevin Cruijssen – 2016-10-19T13:43:59.753

1String c(){return"FKCIIBAVWMG\nN_P\nT_N\nC_C\nS_P\nP_S\nV_C\nS_P\nE_L\nS_B\nJCVCORIBCMG".replace("_","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;").replace(""," ");}(131 bytes) – Numberknot – 2016-10-19T15:11:33.893

You could use some \t instead of space to the replace, two seams to do it perfectly ;) – AxelH – 2016-10-21T08:54:32.347

@AxelH Hmm, the \t spacing is dependent on the OS settings if I'm not mistaken, though. Here in this ideone I had to us 5x \t for the same output. :(

– Kevin Cruijssen – 2016-10-21T09:00:48.313

it is suppose to move to the next 8-column but this is maybe OS depends... – AxelH – 2016-10-21T09:07:35.517

3

Perl, 115 112 bytes

print FKCIIBAVWMG=~s/(.)/\1 /gr.NPTNCCSPPSVCSPELSB=~s/(.)(.)/"\n$1".$"x19 .$2/gre."\nJCVCORIBCMG"=~s/(.)/\1 /gr;

Produces the following output:

F K C I I B A V W M G 
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G 

The first and last rows of output have a trailing space. The code makes use of regex replacements and the fact that if objects are not defined, they are interpreted as strings (e.g. FKCIIBAVWMG is treated as "FKCIIBAVWMG". Couldn't take the quotes out of the last row because of the preceeding newline, which I couldn't finagle anywhere else.

Edit 1: Saved 3 bytes by replacing " " with $", removing the outer parentheses and inserting a space after print, and removing the parentheses around $"x19 and adding a space afterwards (so the . wouldn't be interpreted as a decimal)

Gabriel Benamy

Posted 2016-10-19T12:11:31.433

Reputation: 2 827

You can still save a few bytes : s/(.)/\1 / can be replaced by s/./$& /. Drop the final semicolon. Use say instead of print (for that you'll need to either add -M5.010 or use -E instead of -e, but both are free (see here)). Literal newlines instead of \n.

– Dada – 2016-10-22T12:07:56.333

3

Befunge, 120 bytes

<v"FKCIIBAVWMG NPTNCCSPPSVCSPELSB $JCVCORIBCMG "
:<,*48 ,_v#-*48<
>1-:#v_\,>$52*, :48*-!#v_,54*
^,*84<         ^p19*88$<

First line has the string to be printed in reverse (it looks like it's not, but the code is going backwards on that line). Second line prints the top and bottom rows. Third line and the left side of the fourth line print the middle rows, and the small chunk on the bottom right does an interesting thing: it moves the cursor back to the second row to print out the last line, but after finishing it, it quits.

As you can see on the first line, the strings are separated by spaces to distinguish between the first, middle, and last rows. The spaces can be anything else, and if I used ASCII characters 0-9, I could've easily saved 4 bytes. The $ you see is just a garbage character that has to be there and could be replaced with anything but a space.

user55852

Posted 2016-10-19T12:11:31.433

Reputation:

3

Ruby, 92

Full program, prints to stdout using $> <<

40.times{|i|$><<"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"[i]+(i%29>9?[$/,' '*19][i%2]:' ')}

There are 40 total letters to plot. Letters 10 to 28 alternate between being followed by a newline or ' '*19. The earlier and later letters are separated by single spaces.

Level River St

Posted 2016-10-19T12:11:31.433

Reputation: 22 049

3

J, 77 73 bytes

' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'{~_22}.\,0,.(*+/\),0=*/~5-|i:5

Note that 43 bytes, over half the total, are used just for the string ' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'.

Explanation

First, make a list

   |i:5
5 4 3 2 1 0 1 2 3 4 5
   5-|i:5
0 1 2 3 4 5 4 3 2 1 0

Then make its times table

   */~5-|i:5
0 0  0  0  0  0  0  0  0 0 0
0 1  2  3  4  5  4  3  2 1 0
0 2  4  6  8 10  8  6  4 2 0
0 3  6  9 12 15 12  9  6 3 0
0 4  8 12 16 20 16 12  8 4 0
0 5 10 15 20 25 20 15 10 5 0
0 4  8 12 16 20 16 12  8 4 0
0 3  6  9 12 15 12  9  6 3 0
0 2  4  6  8 10  8  6  4 2 0
0 1  2  3  4  5  4  3  2 1 0
0 0  0  0  0  0  0  0  0 0 0

Then test for equality with zero

   0=*/~5-|i:5
1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1

Flatten it, find the cumulative sums, and multiply elementwise

   ,0=*/~5-|i:5
1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
   +/\,0=*/~5-|i:5
1 2 3 4 5 6 7 8 9 10 11 12 12 12 12 12 12 12 12 12 12 13 14 14 14 14 14 14 14 14 14 14 15 16 16 16 16 16 16 16 16 16 16 17 18 18 18 18 18 18 18 18 18 18 19 20 20 20 20 20 20 20 20 20 20 21 22 22 22 22 22 22 22 22 22 22 23 24 24 24 24 24 24 24 24 24 24 25 26 26 26 26 26 26 26 26 26 26 27 28 28 28 28 28 28 28 28 28 28 29 30 31 32 33 34 35 36 37 38 39 40
   (*+/\),0=*/~5-|i:5
1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0 13 14 0 0 0 0 0 0 0 0 0 15 16 0 0 0 0 0 0 0 0 0 17 18 0 0 0 0 0 0 0 0 0 19 20 0 0 0 0 0 0 0 0 0 21 22 0 0 0 0 0 0 0 0 0 23 24 0 0 0 0 0 0 0 0 0 25 26 0 0 0 0 0 0 0 0 0 27 28 0 0 0 0 0 0 0 0 0 29 30 31 32 33 34 35 36 37 38 39 40

Then join with zeros, split it into sublists of length 22, drop the head of each sublist, and use the values as indices in the string ' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'

   ' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'{~_22}.\,0,.(*+/\),0=*/~5-|i:5
F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G

miles

Posted 2016-10-19T12:11:31.433

Reputation: 15 654

The best I could get using generic string compression is 90 bytes: (' ',@,.~]);._1';FKCIIBAVWMG;N_P;T_N;C_C;S_P;P_S;V_C;S_P;E_L;S_B;JCVCORIBCMG'rplc'_';9#' ' – Conor O'Brien – 2016-10-20T02:22:03.947

@ConorO'Brien Yeah, it's hard to golf string compression in J when other languages have dictionaries and builtin compression. – miles – 2016-10-20T02:35:08.940

@ConorO'Brien I tried golfing your idea a bit more and got it to 76 bytes _11,@,.&' '\'FKCIIBAVWMGN_PT_NC_CS_PP_SV_CS_PE_LS_BJCVCORIBCMG'rplc'_';9#' ' – miles – 2016-10-20T09:22:15.353

3

Actually, 74 bytes

"%s"9⌐α' j;"%s%20s"9α'
j(k'
j"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"#@%

Try it online!

This program works off of the same basic principle as xnor's Python 2 answer.

Explanation (newlines replaced with \n for clarity):

"%s"9⌐α' j                                       ' '.join(["%s"]*11)
;                                                duplicate
"%s%20s"9α'\nj                                   '\n'.join(["%s%20s"]*9)
(                                                move bottom of stack to top
k'\nj                                            '\n'.join(stack)
"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"#@%                    %tuple(longstring)

Mego

Posted 2016-10-19T12:11:31.433

Reputation: 32 998

3

Charcoal, 66 bytes

B²¹¦¹¹F K C I I B A V W M GPNCPSCPLBG M C B I R O C V C JSESVPSCTN

Try it online!

Box(21, 11, 'F K C I I B A V W M GPNCPSCPLBG M C B I R O C V C JSESVPSCTN').

Noncompeting, 36 bytes

ASCII-only

Posted 2016-10-19T12:11:31.433

Reputation: 4 687

3

C#6, 192 190 Bytes

using System.Linq;
string f()=>string.Join("\n","FKCIIBAVWMG~N!P~T!N~C!C~S!P~P!S~V!C~S!P~E!L~S!B~JCVCORIBCMG".Replace("!","         ").Split('~').Select(s=>string.Join(" ",s.Select(c=>c))));

Without trailing space; without trailing newline.

A straightforward solution. Start with the literal string. Replace ! by 9 spaces. Then Split into 11 strings by ~, and further to chars (inner Select). Append a space to each character, then Join back to 11 strings. Finally another Join by newline character.

Link Ng

Posted 2016-10-19T12:11:31.433

Reputation: 593

2

Python 2, 116 Bytes

Pretty straightforward, for whatever reason even though string replacing is so verbose it was the best thing I could come up with. Possibly using re might be shorter.

print' '.join('FKCIIBAVWMG!N@P!T@N!C@C!S@P!P@S!V@C!S@P!E@L!S@B!JCVCORIBCMG').replace(' ! ','\n').replace('@',' '*17)

Kade

Posted 2016-10-19T12:11:31.433

Reputation: 7 463

print'F K C I I B A V W M G\nN@P\nT@N\nC@C\nS@P\nP@S\nV@C\nS@P\nE@L\nS@B\nJ C V C O R I B C M G'.replace('@',' '*19) is also 116 bytes without using join if you want to be more straight-forward. Alternately, print' '.join('FKCIIBAVWMG!N@P!T@N!C@C!S@P!P@S!V@C!S@P!E@L!S@B!JCVCORIBCMG').replace('! ','\n').replace('@',' '*17) is 115 bytes if trailing whitespace is allowed. (The argument to replace is '! ', instead of ' ! '.) – MichaelS – 2016-10-20T04:06:39.777

2

Batch, 171 bytes

@echo F K C I I B A V W M G
@set s=NPTNCCSPPSVCSPELSB
:l
@echo %s:~0,1%                   %s:~1,1%
@set s=%s:~2%
@if not "%s%"=="" goto l
@echo J C V C O R I B C M G

Neil

Posted 2016-10-19T12:11:31.433

Reputation: 95 035

2

C, 171 156 Bytes

i,j;char*b="FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG ";f(){for(i=1;*b;j=i%21==0?putchar(*b++),puts(""),i++,*b++:i<21||i>210?i&1?*b++:32:32,putchar(j),i++);}

Outputs a trailing newline character as well... Could probably be golfed down a bit more.

cleblanc

Posted 2016-10-19T12:11:31.433

Reputation: 3 360

2

GameMaker Language, 148 bytes

I know it's pretty basic, but I don't think this can be beat in GML...

a="                   "return"F K C I I B A V W M G #N"+a+"P#T"+a+"N#C"+a+"C#S"+a+"P#P"+a+"S#V"+a+"C#S"+a+"P#E"+a+"L#S"+a+"B#J C V C O R I B C M G "

Timtech

Posted 2016-10-19T12:11:31.433

Reputation: 12 038

1

Thanks @NiCkNewman, but I've actually used it before on this site quite a few times - https://codegolf.stackexchange.com/search?q=GameMaker

– Timtech – 2016-10-22T14:04:05.273

I see, I was thinking of doing some in GDScript, language from the Godot game engine. But, not sure if it would be ok :) – NiCk Newman – 2016-10-22T21:28:52.263

Ah, if only the board was bigger; string_repeat(" ",19) is the same length as " ". – for Monica – 2016-10-23T10:30:18.087

1@NiCkNewman That should be okay, tell me if you write some :) – Timtech – 2016-10-23T20:34:54.547

@lastresort I know... GML allows tricks with smashing things together but its commands are so verbose... – Timtech – 2016-10-23T20:35:23.693

2

Pip, 64 bytes

63 bytes of code, +1 for -S flag.

.*"NTCSPVSES".sX19.^"PNCPSCPLB"PE^"FKCIIBAVWMG"AE^"JCVCORIBCMG"

Try it online!

Explanation

Operators used:

  • . (binary) concatenates (operates item-wise on lists).
  • X (binary) string-multiplies. (s is a variable preinitialized to " ".)
  • ^ (unary) splits a string into a list of characters.
  • .* is another way to split a string into characters. It consists of unary ., which is a no-op on strings, paired with the * meta-operator, which maps a unary operator to each item in its (iterable) operand. Using .*"..." lets us save a byte over (^"...")--the parentheses would be required because . is higher precedence than ^.
  • PE prepends an element to a list. AE appends an element to a list.

With that background, here's the code step by step:

.*"NTCSPVSES"

['N 'T 'C 'S 'P 'V 'S 'E 'S]

.sX19

["N                   "
 "T                   "
 "C                   "
 "S                   "
 "P                   "
 "V                   "
 "S                   "
 "E                   "
 "S                   "]

.^"PNCPSCPLB"

["N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"]

PE^"FKCIIBAVWMG"

[['F 'K 'C 'I 'I 'B 'A 'V 'W 'M 'G]
 "N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"]

AE^"JCVCORIBCMG"

[['F 'K 'C 'I 'I 'B 'A 'V 'W 'M 'G]
 "N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"
 ['J 'C 'V 'C 'O 'R 'I 'B 'C 'M 'G]]

When this result is autoprinted, the -S flag joins the sublists on spaces and the main list on newlines, giving the desired output.

DLosc

Posted 2016-10-19T12:11:31.433

Reputation: 21 213

2

Perl 5, 92 86 bytes

  • saved 6 bytes thanks to Dada

$a="%s "x11;printf"$a
"."%s%20s
"x9 .$a,FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG=~/./g

Uses sprintf, padding and the string repeat operator x.

simbabque

Posted 2016-10-19T12:11:31.433

Reputation: 487

Nice solution. You can save a few bytes though : replaces \n with literal newlines, you don't need spaces between the x operator and the number that follows, and finally replace split//,xxx with xxx=~/./g. – Dada – 2016-10-21T12:35:06.613

1

Powershell, 95 bytes

Inspired by @AdmBorkBork's answer.

'FKCIIBAVWMG
N0P
T0N
C0C
S0P
P0S
V0C
S0P
E0L
S0B
JCVCORIBCMG'-replace0,(' '*9)-replace'.','$0 '

Explanation

The first replacing operator makes the rectangle 11x11.

FKCIIBAVWMG
N         P
T         N
C         C
S         P
P         S
V         C
S         P
E         L
S         B
JCVCORIBCMG

The second replacing operator inserts a space after each character. The result has trailing spaces.

F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G

mazzy

Posted 2016-10-19T12:11:31.433

Reputation: 4 832

1

Haskell, 128 125 114 bytes

mapM(putStrLn.((:" ")=<<))$"FKCIIBAVWMG":zipWith(\a b->a:"         "++[b])"NTCSPVSES""PNCPSCPLB"++["JCVCORIBCMG"]

Try it here

  • ((:" ")=<<) is concatMap (\a -> [a,' ']) - pads by adding a space behind every letter in its input

Angs

Posted 2016-10-19T12:11:31.433

Reputation: 4 825