39
\$\begingroup\$

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! :)

\$\endgroup\$
17
  • 7
    \$\begingroup\$ I don't mean to be a stickler but... how does one pass Go while advancing to Boardwalk? \$\endgroup\$
    – Sp3000
    Commented Oct 19, 2016 at 12:27
  • 4
    \$\begingroup\$ If you are on boardwalk :) \$\endgroup\$ Commented Oct 19, 2016 at 12:28
  • 8
    \$\begingroup\$ Which you can't get a chance card if you are on boardwalk :( \$\endgroup\$ Commented Oct 19, 2016 at 12:28
  • 27
    \$\begingroup\$ I failed you all \$\endgroup\$ Commented Oct 19, 2016 at 12:29
  • 3
    \$\begingroup\$ Are trailing spaces allowed? \$\endgroup\$
    – Adnan
    Commented Oct 19, 2016 at 16:46

29 Answers 29

36
\$\begingroup\$

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.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Nice Job! That was fast! \$\endgroup\$ Commented Oct 19, 2016 at 12:27
  • 39
    \$\begingroup\$ +1 for (._.). \$\endgroup\$ Commented Oct 19, 2016 at 12:55
  • \$\begingroup\$ ^ was just about to say that ahha \$\endgroup\$
    – John
    Commented Oct 19, 2016 at 23:18
25
\$\begingroup\$

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.
\$\endgroup\$
4
  • 5
    \$\begingroup\$ Thanks for the detailed explanation. It's always interesting to see the process behind answers to code golf questions. :) \$\endgroup\$ Commented Oct 19, 2016 at 19:53
  • 11
    \$\begingroup\$ Code Golf - where it's perfectly normal to see a number in base 250 and base 23. \$\endgroup\$
    – corsiKa
    Commented Oct 19, 2016 at 22:47
  • \$\begingroup\$ Nice compression technique. Why is transposing necessary? \$\endgroup\$ Commented Oct 20, 2016 at 1:53
  • \$\begingroup\$ @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. \$\endgroup\$
    – Dennis
    Commented Oct 20, 2016 at 1:55
16
\$\begingroup\$

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!

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Compressing with 0 instead of D saves a byte •(K·;“…¬È¦z"9äuŸé;TÞîÕs‡ÓÐV9XÒt\<•33B¾9ð×:S11ô» \$\endgroup\$
    – Emigna
    Commented Oct 19, 2016 at 13:41
  • \$\begingroup\$ @Emigna Ah, that's clever! Thanks :). \$\endgroup\$
    – Adnan
    Commented Oct 19, 2016 at 14:58
12
\$\begingroup\$

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 (*'...',).

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Switching to Python 3.5 should save a byte. \$\endgroup\$
    – Dennis
    Commented Oct 20, 2016 at 3:54
9
\$\begingroup\$

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
\$\endgroup\$
9
\$\begingroup\$

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>

\$\endgroup\$
5
  • \$\begingroup\$ I don't think REPL is allowed. \$\endgroup\$ Commented Oct 19, 2016 at 14:38
  • \$\begingroup\$ @NoOneIsHere meta.codegolf.stackexchange.com/a/7844/8478 \$\endgroup\$ Commented Oct 19, 2016 at 17:19
  • 1
    \$\begingroup\$ I managed to shave off another byte. Replace the 1s with spaces and use this regexp instead: .replace(/.( ?)/g,`$& `+`$1`.repeat(17)) \$\endgroup\$
    – Neil
    Commented Oct 19, 2016 at 21:17
  • \$\begingroup\$ 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+' ' \$\endgroup\$ Commented Oct 20, 2016 at 1:56
  • \$\begingroup\$ @Neil thanks, love your approach! \$\endgroup\$ Commented Oct 21, 2016 at 8:25
7
\$\begingroup\$

///, 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!

\$\endgroup\$
8
  • \$\begingroup\$ @ETHproductions Wrong link maybe? I can't save any byte like that. \$\endgroup\$ Commented Oct 19, 2016 at 12:46
  • \$\begingroup\$ Isn't this 98 bytes if you remove the space after the Gs on the first and last line? \$\endgroup\$
    – Emigna
    Commented Oct 19, 2016 at 13:46
  • 1
    \$\begingroup\$ @Emigna Whole discussion about the extra spaces. \$\endgroup\$ Commented Oct 19, 2016 at 13:47
  • 1
    \$\begingroup\$ @Emigna I know, but the exact output contains them, so I won't remove them. \$\endgroup\$ Commented Oct 19, 2016 at 13:51
  • \$\begingroup\$ My bad, try this. \$\endgroup\$ Commented Oct 19, 2016 at 14:23
6
\$\begingroup\$

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

\$\endgroup\$
5
\$\begingroup\$

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
\$\endgroup\$
4
\$\begingroup\$

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

\$\endgroup\$
4
\$\begingroup\$

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']))
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I 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 \$\endgroup\$
    – ElPedro
    Commented Oct 19, 2016 at 17:23
4
\$\begingroup\$

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'
\$\endgroup\$
3
  • \$\begingroup\$ 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). \$\endgroup\$
    – Dada
    Commented Oct 19, 2016 at 15:23
  • \$\begingroup\$ @Dada Ahhh, much nicer! Thanks! \$\endgroup\$ Commented Oct 19, 2016 at 15:45
  • \$\begingroup\$ "much nice" would have been finding a 40 bytes solution, but thanks :D \$\endgroup\$
    – Dada
    Commented Oct 19, 2016 at 20:10
4
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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
\$\endgroup\$
8
  • 1
    \$\begingroup\$ String 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) \$\endgroup\$ Commented Oct 19, 2016 at 13:29
  • \$\begingroup\$ @BassdropCumberwubwubwub Umm.. this outputs only 3 spaces between the 'vertical walls', instead of 19.. Here is an ideone of your code. \$\endgroup\$ Commented Oct 19, 2016 at 13:34
  • \$\begingroup\$ Hence my note, there should be more spaces in s but stackexchange removed them. Here's the ideone, now even at 142 bytes \$\endgroup\$ Commented Oct 19, 2016 at 13:43
  • \$\begingroup\$ @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 \$\endgroup\$ Commented Oct 19, 2016 at 13:43
  • 1
    \$\begingroup\$ String 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) \$\endgroup\$
    – Numberknot
    Commented Oct 19, 2016 at 15:11
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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
\$\endgroup\$
3
  • \$\begingroup\$ 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#' ' \$\endgroup\$ Commented Oct 20, 2016 at 2:22
  • \$\begingroup\$ @ConorO'Brien Yeah, it's hard to golf string compression in J when other languages have dictionaries and builtin compression. \$\endgroup\$
    – miles
    Commented Oct 20, 2016 at 2:35
  • \$\begingroup\$ @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#' ' \$\endgroup\$
    – miles
    Commented Oct 20, 2016 at 9:22
3
\$\begingroup\$

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)
\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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)

\$\endgroup\$
1
  • \$\begingroup\$ 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. \$\endgroup\$
    – Dada
    Commented Oct 22, 2016 at 12:07
3
\$\begingroup\$

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

\$\endgroup\$
2
\$\begingroup\$

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)
\$\endgroup\$
1
  • \$\begingroup\$ 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 ' ! '.) \$\endgroup\$
    – MichaelS
    Commented Oct 20, 2016 at 4:06
2
\$\begingroup\$

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
\$\endgroup\$
2
\$\begingroup\$

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 "
\$\endgroup\$
5
  • 1
    \$\begingroup\$ Thanks @NiCkNewman, but I've actually used it before on this site quite a few times - codegolf.stackexchange.com/search?q=GameMaker \$\endgroup\$
    – Timtech
    Commented Oct 22, 2016 at 14:04
  • \$\begingroup\$ I see, I was thinking of doing some in GDScript, language from the Godot game engine. But, not sure if it would be ok :) \$\endgroup\$ Commented Oct 22, 2016 at 21:28
  • \$\begingroup\$ Ah, if only the board was bigger; string_repeat(" ",19) is the same length as " ". \$\endgroup\$
    – user58632
    Commented Oct 23, 2016 at 10:30
  • 1
    \$\begingroup\$ @NiCkNewman That should be okay, tell me if you write some :) \$\endgroup\$
    – Timtech
    Commented Oct 23, 2016 at 20:34
  • \$\begingroup\$ @lastresort I know... GML allows tricks with smashing things together but its commands are so verbose... \$\endgroup\$
    – Timtech
    Commented Oct 23, 2016 at 20:35
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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. \$\endgroup\$
    – Dada
    Commented Oct 21, 2016 at 12:35
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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