让我更多!


19

让我更多!我告诉你宽度,全麦饼干的数量,巧克力的数量和棉花糖的数量。一个例子:

输入:

宽度:10 格雷厄姆:3 巧克力:2 棉花糖:1

输出:

GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG
CCCCCCCCCC
CCCCCCCCCC
MMMMMMMMMM
GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG

它是那么容易?嗯...是的

请注意,输入应该是函数或程序的参数列表,而不是字符串。您可以选择第一个是Width,然后选择Graham,但是任何顺序都可以。

完整的测试用例,如果您有兴趣。

堆栈代码段(用于测试等)

这是为了测试输出。

var smore = function(width, graham, chocolate, marshmallow){
	return ("G".repeat(width) + "\n").repeat(graham) + 
	("C".repeat(width) + "\n").repeat(chocolate) + 
	("M".repeat(width) + "\n").repeat(marshmallow) + 
	("G".repeat(width) + "\n").repeat(graham);
};
Snippetify(smore);
<script src="https://programmer5000.com/snippetify.min.js"></script>
Width: <input type = "number">
Graham: <input type = "number">
Chocolate: <input type = "number">
Marshmallow: <input type = "number">
<button>Try it out!</button>
<pre data-output></pre>

笔记:

  • 您可以在最后一行的末尾添加尾随换行符。您也可以使用a \代替换行符。
  • 这是
  • 任何问题?以下评论:

21
我已将您的“让我为您准备的Google”链接删除。真的不好笑。
水平河圣

1
@FelipeNardiBatista是的。
程序员

1
某些答案假设输入顺序和格式灵活(如PPCG一样),但是挑战似乎需要特定的顺序并排除字符串(不知道这意味着什么)。你能澄清一下吗?
路易斯·门多

2
感谢您的澄清。然后,您应该重新输入该句子,输入内容应该是函数或程序的参数列表,而不是字符串,第一个是Width,然后是Graham,等等。我个人会说类似“输入格式像往常一样灵活”
Luis Mendo

4
@ programmer5000但是为什么呢?如果他们投票否决,那很有可能是90%,因为他们认为这是一个无聊而琐碎的挑战。此外,告诉人们进行解释或收回是很不礼貌的。他们有权不加评论地投票。
Rɪᴋᴇʀ

Answers:


2

果冻,11字节

ṁ4“GCMG”x×Y

在线尝试!

怎么运行的

ṁ4“GCMG”x×Y  Main link. Left argument: g, c, m. Right argument: w

ṁ4           Mold 4; repeat g, c, m until length 4 is reached. Yields [g, c, m, g].
  “GCMG”x    Repeat 'G' g times, then 'C' c times, then 'M' m times, and finally
             'G' g times. This yields a string.
         ×   Multiply each character w times. This is essentially a bug, but
             Jelly's × behaves like Python's * (and vectorizes), so it can be
             abused for character repetition.
          Y  Join, separating by linefeeds.


8

05AB1E21 19 19字节

"GCMG"S×|D«‚øvy`.D»

在线尝试!

-2多亏了我的监督和Emigna。

"GCMG"S×            # Push GCMG, separate, duplicate n times.
        |D«         # Push rest of inputs, doubled.
           ‚ø       # Wrap GCMG array and input array, then zip them into pairs.
             vy`.D» # For each pair, print n of G/C/M/G.

(参见Emigna的答案,最好是:https ://codegolf.stackexchange.com/a/116787/59376 )


1
您似乎不小心©在其中留了一个。
Emigna '17

1
您也可以替换为¬¸D因为压缩时多余的元素会丢失。
Emigna '17

@Emigna我既喜欢又讨厌该功能。
Magic Octopus Urn'Apr

是的,它通常很烦人,但有时(和现在一样)变得有用:)
Emigna

8

JavaScript(ES6),71个字节

(W,G,C,M)=>[...'GCMG'].map(X=>`${X.repeat(W)}
`.repeat(eval(X))).join``

哇,击败其他3个JavaScript答案!


很好,很好-请投票。
毛茸茸的

7

MATL,17个字节

'GCMG'iK:)Y"!liX"

输入格式为:第一输入[G, C, M],第二输入W

在线尝试!

举例说明

考虑输入[3 2 1]10

'GCMG' % Push this string
       % STACK: 'GCMG'
i      % Take first input: array of three numbers
       % STACK: 'GCMG', [3 2 1]
K:     % Push [1 2 3 4]
       % STACK: 'GCMG', [3 2 1], [1 2 3 4]
)      % Index (modular, 1-based). This repeats the first entry of the input array
       % STACK: 'GCMG', [3 2 1 3]
Y"     % Run-length decoding
       % STACK: 'GGGCCMGGG'
!      % Transpose. Gives a column vector of chars
       % STACK: ['G'; 'G'; 'G'; 'C'; 'C'; 'M'; 'G'; 'G'; 'G']
l      % Push 1
       % STACK: ['G'; 'G'; 'G'; 'C'; 'C'; 'M'; 'G'; 'G'; 'G'], 1
i      % Take second input: number
       % STACK: ['G'; 'G'; 'G'; 'C'; 'C'; 'M'; 'G'; 'G'; 'G'], 1, 10
X"     % Repeat the specified numbers of times along first and second dimensions
       % STACK: ['GGGGGGGGGG';'GGGGGGGGGG';'GGGGGGGGGG';'CCCCCCCCCC';...;'GGGGGGGGGG']
       % Implicitly display

7

C#,204字节


打高尔夫球

(w,g,c,m)=>{string G="\n".PadLeft(++w,'G'),C="\n".PadLeft(w,'C'),M="\n".PadLeft(w,'M'),o="".PadLeft(g,'G');o+="".PadLeft(m,'M')+"".PadLeft(c,'C')+o;return o.Replace("G",G).Replace("C",C).Replace("M",M);};

不打高尔夫球

( w, g, c, m ) => {
   string
      G = "\n".PadLeft( ++w, 'G' ),
      C = "\n".PadLeft( w, 'C' ),
      M = "\n".PadLeft( w, 'M' ),
      o = "".PadLeft( g, 'G' );

   o +=
      "".PadLeft( m, 'M' ) +
      "".PadLeft( c, 'C' ) +
      o;

   return o
      .Replace( "G", G )
      .Replace( "C", C )
      .Replace( "M", M );
};

非高尔夫可读

// Function with 4 parameters
//   w : Width
//   g : Graham
//   c : Chocolate
//   m : Marshmallow
( w, g, c, m ) => {

   // Initialization of vars with the contents
   //    of each line, with a new line at the end
   string
      G = "\n".PadLeft( ++w, 'G' ),
      C = "\n".PadLeft( w, 'C' ),
      M = "\n".PadLeft( w, 'M' ),

      // Trick to reduce the byte count
      //   Initialize the output with n 'G's
      o = "".PadLeft( g, 'G' );

   // Add again n 'M's and n 'C's
   //   Append the 'G's at the end.
   o +=
      "".PadLeft( m, 'M' ) +
      "".PadLeft( c, 'C' ) +
      o;

   // Replce every instance of 'G'/'C'/'M'
   //    with the full line
   return o
      .Replace( "G", G )
      .Replace( "C", C )
      .Replace( "M", M );
};

完整代码

using System;
using System.Collections.Generic;

namespace Namespace {
   class Program {
      static void Main( String[] args ) {
         Func<Int32, Int32, Int32, Int32, String> f = ( w, g, c, m ) => {
            string
               G = "\n".PadLeft( ++w, 'G' ),
               C = "\n".PadLeft( w, 'C' ),
               M = "\n".PadLeft( w, 'M' ),
               o = "".PadLeft( g, 'G' );

            o +=
               "".PadLeft( m, 'M' ) +
               "".PadLeft( c, 'C' ) +
               o;

            return o
               .Replace( "G", G )
               .Replace( "C", C )
               .Replace( "M", M );
         };

         List<Tuple<Int32, Int32, Int32, Int32>>
            testCases = new List<Tuple<Int32, Int32, Int32, Int32>>() {
               new Tuple<Int32, Int32, Int32, Int32>( 1, 1, 1, 1 ),
               new Tuple<Int32, Int32, Int32, Int32>( 1, 1, 1, 2 ),
               new Tuple<Int32, Int32, Int32, Int32>( 1, 1, 2, 1 ),
               //
               // ...
               //
               // The link above contains the code ready to run
               //    and with every test from the pastebin link
               //
               // Yes, it contains 342 tests ready to run.
               //
               // I can barely fit every test on a 1080p screen...
               //    ... and there's 6 tests per line... Jebus...
               //
            };

         foreach( var testCase in testCases ) {
            Console.WriteLine( $"Input:\nWidth: {testCase.Item1,3} Graham: {testCase.Item2,3} Chocolate: {testCase.Item3,3} Marshmellow: {testCase.Item4,3}\nOutput:\n{f( testCase.Item1, testCase.Item2, testCase.Item3, testCase.Item4 )}\n" );
         }

         Console.ReadLine();
      }
   }
}

发布

  • 1.0 - 204 bytes-初始溶液。

笔记


感激!:D
auhmaan '17

7

05AB1E17 16字节

由于使用了carusocomputing,因此节省了1个字节。

"GCMG"S×vy²Nè.D»

在线尝试!

输入顺序为 W, [G,C,M]

说明

10, [3,2,1] 用作示例。

"GCMG"S           # push the list ['G','C','M','G']
       ×          # repeat each W times
                  # STACK: ['GGGGGGGGGG', 'CCCCCCCCCC', 'MMMMMMMMMM', 'GGGGGGGGGG']
        v         # for each [string, index] y,N in the list
          ²Nè     # get the amount of layers at index N from the [G,C,M] list
         y   .D   # duplicate the string y that many times
               »  # join strings by newlines

1
"GCMG"S×vy²Nè.D»神奇双胞胎,激活!表格,05AB1E代码!此外,参数被换,但它仍然是16
魔术八达通瓮城

@carusocomputing:这样做的好处是不会在堆栈上留下未打印的废话,但是对我来说,这似乎同样不可简化。
Emigna '17

1
它仍然少了1个字节,并且会击败您与MATL的关系;)。
魔术章鱼缸

@carusocomputing:哦,那是什么时候发生的?我确定看到的时候是17岁。真好!;)
Emigna '17

当我意识到自己是个白痴后,我经常发布愚蠢的东西并对其进行编辑1分钟。
魔术章鱼缸

6

Ruby,47个字节

->w,g,c,m{puts r=[?G*w]*g,[?C*w]*c,[?M*w]*m,r}

多亏了ventero

Ruby,51个字节

->w,g,c,m{(?G*g+?C*c+?M*m+?G*g).chars{|i|puts i*w}}

像这样打电话:

f=->w,g,c,m{(?G*g+?C*c+?M*m+?G*g).chars{|i|puts i*w}}

f[10,3,2,1]

->w,g,c,m{puts r=[?G*w]*g,[?C*w]*c,[?M*w]*m,r}有点短
Ventero

5

PowerShell,49字节

$a,$b=$args;0..2+0|%{,("$('GCM'[$_])"*$a)*$b[$_]}

在线尝试!

将输入作为四个命令行参数,width graham chocolate marshmallow将第一个$a和第二个参数存储$b(隐式地作为数组)。从范围开始循环0,1,2,0。每个循环,我们索引成字符串GCM,将其重新char为字符串,然后乘以$a(宽度),然后使用逗号运算符,,通过乘以适当的索引$b(即,将多少层)。这些结果字符串数组全部保留在管道上,并且输出是隐式的,元素之间带有换行符。


5

C, 108105字节

感谢@Quentin节省了3个字节!

#define F(i,c)for(;i--;puts(""))for(j=w;j--;)putchar(c);
i,j;f(w,g,c,m){i=g;F(i,71)F(c,67)F(m,77)F(g,71)}

在线尝试!


1
#define F(i,c)for(;i--;puts(""))for(j=w;j--;)putchar(c);保存三个字节:)
Quentin

@Quentin谢谢!我不知道为什么我会首先错过它:)
Steadybox

4

批处理,146字节

@set s=
@for /l %%i in (1,1,%1)do @call set s=G%%s%%
@for %%w in (%2.%s% %3.%s:G=C% %4.%s:G=M% %2.%s%)do @for /l %%i in (1,1,%%~nw)do @echo%%~xw

依靠的晦涩行为,echo通常可以忽略它们之间的符号echo和要回显的文本,以将四个循环折叠为嵌套循环。


4

V,22字节

éGÄÀäjMoC
MÀÄkÀÄHdêÀP

在线尝试!

十六进制转储:

00000000: e947 c4c0 e46a 4d6f 430a 4d1b c0c4 6bc0  .G...jMoC.M...k.
00000010: c448 64ea c050                           .Hd..P

输入顺序为

Graham, Marshmallow, Chocolate, Width

说明:

éG                  " Insert 'G'
  Ä                 " Duplicate this line
   Àäj              " *arg1* times, duplicate this line and the line below it
      M             " Move to the middle line
       o            " Open up a newline, and enter insert mode
        C<cr>M<esc> " Insert 'C\nM'
ÀÄ                  " Make *arg2* copies of this line (Marshmallow)
  k                 " Move up one line
   ÀÄ               " Make *arg3* copies of this line (Chocolate)
     H              " Move to the first line
      dê            " Delete this column
        ÀP          " And paste it horizontally *arg4* times

你能补充一个解释吗?
程序员

@ programmer5000好!查看我的编辑
DJMcMayhem

4

Excel,104个字节

好家伙!需要换行符的公式。

=REPT(REPT("G",A1)&"
",A2)&REPT(REPT("C",A1)&"
",A3)&REPT(REPT("M",A1)&"
",A4)&REPT(REPT("G",A1)&"
",A2)

A1有宽度
A2有格雷厄姆
A3有巧克力
A4有锦葵


如果允许预格式化,则可以格式化“垂直文本”的单元格并将公式缩短为65个字节:

=REPT(REPT("G",A2)&REPT("C",A3)&REPT("M",A4)&REPT("G",A2)&"
",A1)

4

果冻,13 个字节

“GCM”ẋ"ṁ4Fẋ€Y

二进位程序。输入为:[Graham's, Chocolates, Marshmallows]Width

在线尝试!

怎么样?

“GCM”ẋ"ṁ4Fẋ€Y - Main link: [g,c,m], w    e.g. [1,2,1], 2
“GCM”         - literal ['G', 'C', 'M']
      "       - zip that and [g,c,m] with the dyadic operation:
     ẋ        -     repeat list               [['G'],['C','C'],['M']]
       ṁ4     - mould like [1,2,3,4]          [['G'],['C','C'],['M'],['G']]
         F    - flatten                       ['G','C','C','M','G']
          ẋ€  - repeat €ach w times           [['G','G'],['C','C'],['C','C'],['M','M'],['G','G']]
            Y - join with line feeds          ['G','G','\n','C','C','\n','C','C','\n','M','M','\n','G','G']
              - implicit print                GG
                                              CC
                                              CC
                                              MM
                                              GG

3

PHP,85字节

for($m=$argv;$i++<4;)for($c=$m[_2342[$i]]*$m[1];$c;)echo$c--%$m[1]?"":"\n",_GCMG[$i];

要么

for($m=$argv;$i++<4;)for($c=$m[_2342[$i]];$c--;)echo"\n".str_pad("",$m[1],_GCMG[$i]);

在线版本

PHP,96字节

<?[$n,$w,$G,$C,$M]=$argv;for(;$i<4;$i++)for($t=${"$n[$i]"};$t--;)echo"\n".str_pad("",$w,$n[$i]);

在线版本

展开式

[$n,$w,$G,$C,$M]=$argv; # $argv[0] must contain a file beginning with "GCMG"
for(;$i<4;$i++) # Take the first 4 values of the filename
for($t=${"$n[$i]"};$t--;) # How many rows should be printed
echo"\n".str_pad("",$w,$n[$i]); # print $w times the actual letter

3

05AB1E,14个字节

码:

…GCM‚øü׬)˜S×»

使用CP-1252编码。在线尝试!

说明:

…GCM              # Push the string "GCM"
    ‚             # Wrap with the input
     ø            # Transpose the array
      ü×          # Compute the string product of each element (['A', 3] --> 'AAA')
        ¬)˜       # Get the last element and append to the list
           S      # Split the list
            ×     # Vectorized string multiplication with the second input
             »    # Join by newlines and implicitly print

3

Python 26757个字节

(编辑:现在允许使用矩阵,无需换行来联接它。)

def s(w,g,c,m):g=['G'*w]*g;print g+['C'*w]*c+['M'*w]*m+g

3

C#(150字节)

void S(int w,int g,int c,int m){P(w,g,'G');P(w,c,'C');P(w,m,'M');P(w,g,'G');}void P(int w,int i,char c){while(i-->0)Console.Write("\n".PadLeft(w,c));}

取消高尔夫:

void SMores(int w, int g, int c, int m)
{
    Print(w,g,'G');
    Print(w,c,'C');
    Print(w,m,'M');
    Print(w,g,'G');
}
void Print(int w, int i, char c)
{
    while(i-->0)
        Console.Write("\n".PadLeft(w,c));
}

3

Java,138个字节

String s(int w,int g,int c,int m){String b="";int i=-g-c,j;for(;i++<g+m;){for(j=0;j++<w;)b+=i<=-c|i>m?'G':i<=0?'C':'M';b+="\n";}return b;}

在线尝试!

说明:

String s(int w, int g, int c, int m) {
    String b = "";
    int i = -g - c, j;              // i is the layer
    for (; i++ < g + m;) {          // Repeat (G+C+M+G) times, starting from -g-c to m+g 
                                    //Layer 0 is the last chocolate layer

        for (j = 0; j++ < w;) {     // Repeat W times
            b += 
                i <= -c | i > m ? 'G': //If before the chocolate or after the marshmellow, output a G
                i <= 0 ? 'C' :      // Else if equal or before last chocolate layer output C
                'M';                //Otherwise output an M
        }
        b += "\n";
    }
    return b;
}


3

斯威夫特(138) 137 134 130字节

由于节省了7个字节 @Kevin

let f=String.init(repeating:count:)
let r={w,g,c,m in f(f("G",w)+"\n",g)+f(f("C",w)+"\n",c)+f(f("M",w)+"\n",m)+f(f("G",w)+"\n",g)}

有两个函数返回期望值:f是一个辅助函数和r是实际的类似于lamdba的函数,可生成输出。用法: print(r(10,3,2,1))

一探究竟!


您可以通过直接引用字符串初始化程序(var f=String.init(repeating:count:);)来保存几个字符。而且它不会节省您任何角色,但不会花费任何费用,因此他们都应该做到let
凯文

通过删除rlet r={f(f("G",$0)+"\n",$1)+f(f("C",$0)+"\n",$2)+f(f("M",$0)+"\n",$3)+f(f("G",$0)+"\n",$1)})中的显式参数,还有3个
凯文

@Kevin谢谢,我不知道您可以将值初始化为以下内容:f=String.init(repeating:count:)...
Xcoder先生17年

@Kevin关于您的第二个建议,似乎超出了UTF-8中的字节数,检查了TIO上的字节数,不知道为什么
Xcoder先生17年


2

JavaScript(ES6),91字节

包括结尾的换行符。

f=

(w,g,c,m)=>(b=(`G`[r=`repeat`](w)+`
`)[r](g))+(`C`[r](w)+`
`)[r](c)+(`M`[r](w)+`
`)[r](m)+b

console.log(f(10,3,2,1))


2

JS(ES6),87个字节

x=(w,g,c,m)=>(f=>f`Gg`+f`Cc`+f`Mm`+f`Gg`)(([[x,y]])=>(x.repeat(w)+`
`).repeat(eval(y)))

x充当独立的lambda函数。结果包含尾随换行符。

尝试以下代码段:


2

C,90个字节(基于Steadybox的答案

重命名变量,并利用字符串化预处理程序运算符缩减宏参数。我希望将这个想法发布为自己的答案是可以的:)

#define F(x)for(i=x;i--;puts(""))for(j=w;j--;)printf(#x);
i,j;f(w,G,C,M){F(G)F(C)F(M)F(G)}

TIO链接


会给予好评,但命中投票限制:(
programmer5000

2

F#(148 99字节)

let s w q="GCMG"|>Seq.iteri(fun i c->for j in 1..(q|>Seq.item(i%3))do printf"%A"("".PadLeft(w,c)))

用法:

s 10 [2;3;4]

取消高尔夫:

let smores width quantities =
    "GCMG"
    |>Seq.iteri(fun i char ->
        for j in 1..(quantities|>Seq.nth(i%3))
            do printf "%A" ("".PadLeft(width,char))) 

我还是F#的新手,所以如果我做任何奇怪或愚蠢的事情,请告诉我。


到F#的链接会很好。
程序员

2

的JavaScript ES6,69个 68 66字节

感谢@Arnauld打高尔夫球一个字节

a=>b=>"GCMG".replace(/./g,(c,i)=>`${c.repeat(a)}
`.repeat(b[i%3]))

在线尝试!

说明

接收咖喱格式的输入 (Width)([Graham,Chocolate,Marshmallow])

使用.replace(/./g,...)GCMG函数的返回值替换字符串中的每个字符(c,i)=>`${c.repeat(a)} `.repeat(b[i%3])

`${c.repeat(a)} `创建格雷厄姆饼干的每一行并添加换行符, .repeat(b[i%3])以所需次数重复此行


使用replace()将节省一个字节:a=>"GCMG".replace(/./g,(c,i)=>`${c.repeat(a[0])}\n`.repeat(a[1+i%3]))
Arnauld

1

JS(ES6),111个字节

n=`
`,G="G",C="C",M="M",r=(s,t)=>s.repeat(t),(w,g,c,m)=>r(r(G,w)+n,g)+r(r(C,w)+n,c)+r(r(M,w)+n,m)+r(r(G,w)+n,g)

1

Mathematica 102字节(100个字符)

听说直到v12都没有内置s'mores。

s=StringRepeat;StringReplace[s@@@({Characters@"GCMG",#/.#[[4]]->#[[1]]})<>"",x_:>x~s~#[[4]]<>"\n"]&

使用首先建立一列的想法非常简单。长函数名称浪费35个字节。一个看起来像盒子的符号实际上是一个转置字符,可以很好地粘贴到Mathematica中。

用法: %@{Graham, Chocolate, Marshmallows, Width} 例如 %@{3, 2, 1, 11}


1

Java 7,226字节

String c(int w,int g,int c,int m){return x(w,'G',g)+x(w,'C',c)+x(w,'M',m)+x(w,'G',g);}String x(int w,char c,int x){String r="";for(;x-->0;r+=x(w,c));return r;}String x(int w,char c){String r="";for(;w-->0;r+=c);return r+"\n";}

或(也为226个字节):

String c(int w,int g,int c,int m){return x(w,71,g)+x(w,67,c)+x(w,77,m)+x(w,71,g);}String x(int...a){String r="";for(;a[2]-->0;r+=x(a[0],(char)a[1]));return r;}String x(int w,char c){String r="";for(;w-->0;r+=c);return r+"\n";}

说明:

String c(int w,int g,int c,int m){  // Main method with four integer parameters and String return-type
  return x(w,'G',g)                 //  Return all Graham-rows
        +x(w,'C',c)                 //   plus all Chocolate-rows
        +x(w,'M',m)                 //   Plus all Marshmallon-rows
        +x(w,'G',g);                //   Plus all Graham-rows again
}                                   // End of main method

String x(int w,char c,int x){       // Separate method (1) with two integers & character parameters and String return-type
  String r="";                      //  Result-String
  for(;x-->0;                       //  For the given amount of rows of a certain type
             r+=x(w,c)              //   Append the result-String with a row of the given character
  );                                //  End of for-loop (implicit / no body)
  return r;                         //  Return the result-String
}                                   // End of separate method (1)

String x(int w,char c){             // Separate method (2) with integer and character parameters and String return-type
  String r="";                      //  Result-String
  for(;w-->0;                       //  For the amount given as width
             r+=c                   //   Append the character to the row
  );                                //  End of for-loop (implicit / no body)
  return r+"\n";                    //  Return the result-String including a new-line
}                                   // End of separate method (2)

测试代码:

在这里尝试。

class M{
  String c(int w,int g,int c,int m){return x(w,'G',g)+x(w,'C',c)+x(w,'M',m)+x(w,'G',g);}String x(int w,char c,int x){String r="";for(;x-->0;r+=x(w,c));return r;}String x(int w,char c){String r="";for(;w-->0;r+=c);return r+"\n";}

  public static void main(String[] a){
    System.out.print(new M().c(10,3,2,1));
  }
}

输出:

GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG
CCCCCCCCCC
CCCCCCCCCC
MMMMMMMMMM
GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG

1
不错...对于Java!
程序员

1
@ programmer5000呵呵,谢谢!我喜欢在Java 7中(有时8)高尔夫,虽然我不认为它会永远甚至与其他竞争的答案..“有些竞争”与Java的答案,唯一一次是与这8个字节的答案这19个字节的答案,实际上是第一次超越Python。; p尽管带有1或2字节提交内容的那些高尔夫语言当然仍然使Java尘埃落定。
凯文·克鲁伊森

1

Haskell,91字节

import Data.List
(#)=replicate
f w g c m=intercalate"\n"$map(w#)$g#'G'++c#'C'++m#'M'++g#'G'

应该很不言自明。由于在注释中指出允许使用字符矩阵,因此下面是一个58字节的版本,该版本返回字符串列表(每层一个):

(#)=replicate
f w g c m=map(w#)$g#'G'++c#'C'++m#'M'++g#'G'
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.