17
\$\begingroup\$

Challenge:

Your task is to use any language to output that language's name times the number of character's in its name.

  • Use the common name or acronym of the language.
  • If there are multiple versions of a language, you need not include the version number.
  • The capitalization matters.

Examples:

PHP -> PHPPHPPHP
Java -> JavaJavaJavaJava
C++ -> C++C++C++
Python 3 -> PythonPythonPythonPythonPythonPython
JavaScript -> JavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScript
\$\endgroup\$
24
  • 31
    \$\begingroup\$ Tasks that depend on a language's name are a form of disadvantaging some languages by arbitrary criteria. \$\endgroup\$ Commented Dec 17, 2017 at 15:08
  • 18
    \$\begingroup\$ I think this challenge would have been a lot more interesting if the repetition count was supposed to be our bytecount... \$\endgroup\$
    – Maya
    Commented Dec 17, 2017 at 16:53
  • 15
    \$\begingroup\$ And because it hasn't been said yet: Welcome to PPCG! I hope you stick around despite your probably confusing first impression of people telling you that this is not a good challenge while one answer after the other arrives. \$\endgroup\$
    – Laikoni
    Commented Dec 17, 2017 at 21:06
  • 3
    \$\begingroup\$ @DonielF is that shortest though? \$\endgroup\$
    – Quintec
    Commented Dec 18, 2017 at 20:09
  • 4
    \$\begingroup\$ IMO this is unclear. Use the common name suggests that, for example, JS could be used for JavaScript. But what's to stop me saying that my language "Language" is more commonly known as "L"? \$\endgroup\$
    – FlipTack
    Commented Dec 24, 2017 at 19:25

97 Answers 97

1
\$\begingroup\$

Charcoal, 10 bytes

×Charcoal⁸

Try it online! Alternatively, also 10 bytes:

×⁸Charcoal
F⁸Charcoal

More idiomatic for 13 bytes would be to say:

≔Charcoalθ⭆θθ
≔CharcoalθFθθ
\$\endgroup\$
1
\$\begingroup\$

Clean, 29 bytes

c="CleanCleanCleanCleanClean"

Because actually doing anything requires import StdEnv, it's shorter to just hardcode.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

ReRegex, 17 bytes

a/ReRegex/aaaaaaa

Potentially one of the most simple ReRegex answers I've ever written.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Bean, 15 bytes

xxd-style hexdump:

00000000: 53d0 80a3 8100 2080 b525 3dc2 e5e1 6e    SÐ.£.. .µ%=Âåán

JavaScript equivalent:

'Bean'.repeat(4)

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Clojure, 49 37 bytes

12 bytes saved thanks to @cliffroot

(print(apply str(repeat 7"Clojure")))

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ you can use apply str instead of clojure.string/join ? \$\endgroup\$
    – cliffroot
    Commented Dec 18, 2017 at 9:36
  • \$\begingroup\$ @cliffroot nice trick. thanks! \$\endgroup\$
    – Uriel
    Commented Dec 18, 2017 at 10:40
1
\$\begingroup\$

This=That, 57 bytes

a=This=That
i=0
while loop j=<9
a=print
while loop j=end

This does exactly what you think it does. The string stored to a is printed nine times, accomplished by the loop.

The idea I get from the Esolangs page is that that equals sign in the first line is part of the string literal, not an assignment operator.

Thanks to @FrownyFrog for pointing out an error.

\$\endgroup\$
0
1
\$\begingroup\$

Ruby, 12 bytes

$><<"Ruby"*4

Because Kaiser Chiefs.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Decimal, 52 bytes

13068101099105109097108D117D91D00D30101D111D42D591D5

Try it online!

Ungolfed / explanation:

13068101099105109097108D 117D   ; push "Decimal", push 17
91D                             ; create jump point 1
  00D 301 01D                   ; set DSI to 0 ("Bitwise"), print, set back to 1 (initially 7)
  111D 42D                      ; push 1, subtract from previous SI
5 91D 5                         ; if DSI truthy, jump to point 1

Fun fact that I just remembered: Decimal doesn't care about the "top of stack" like most stack-based esolangs; it instead operates on a "default stack index" that can be modified at will, allowing for rather easy stack manipulation.

\$\endgroup\$
1
\$\begingroup\$

Brain-Flak, 229 bytes

((()()()()()){}){({}<(((((((((((((()()()){}){}()){}){}()){}()))<({}[(()()()()()){}])>())[(()()()){}])<(((((()()()()())){}{})){}{})>(()()()()){})[()()()()()])[(()()()()){}])((()()()()){}){}())(((((()()()()){}){}){}()){})>[()])}{}

Try it online!

This is 228 bytes of code, and +1 for the -A flag.

\$\endgroup\$
1
\$\begingroup\$

T-SQL, 76 67 bytes

declare @i char(5)='T-SQL',@ int=1 a:print @i set @+=1if(@<6)goto a
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can save up to 11 bytes by using @i+=1 instead of @i=@i+1, change the condition to @i<6, swapping the variable names and replacing the WHILE with a GOTO and IF. \$\endgroup\$
    – WORNG ALL
    Commented Dec 18, 2017 at 19:37
1
\$\begingroup\$

C, 20 bytes

main(){printf("C");}

Try it online!

\$\endgroup\$
2
  • 3
    \$\begingroup\$ You can save a few bytes by using puts instead \$\endgroup\$ Commented Dec 18, 2017 at 3:53
  • \$\begingroup\$ And even more by making it a function, f(){puts("C");} \$\endgroup\$
    – MD XF
    Commented Dec 26, 2017 at 22:15
1
\$\begingroup\$

Scala 27 16 bytes

print("Scala"*5)
\$\endgroup\$
3
  • \$\begingroup\$ I don't know Scala, but would assigning it to a variable be shorter than writing it twice? \$\endgroup\$ Commented Dec 19, 2017 at 14:37
  • 1
    \$\begingroup\$ or just using 5 instead of "Scala".size \$\endgroup\$
    – Giuseppe
    Commented Dec 19, 2017 at 14:40
  • \$\begingroup\$ Assigning to a variable takes 29 bytes unfortunately. And yes @Giuseppe I'm dumb.... \$\endgroup\$ Commented Dec 19, 2017 at 14:42
1
\$\begingroup\$

JavaScript 58 54 bytes

a='',f=i=>i<9?(f(i+1),a+="JavaScript"):0;f(0);alert(a)

Solution using document.write (57 53 bytes)

(f=i=>{i<9?f(i+1):0;document.write("JavaScript")})(0)
\$\endgroup\$
1
  • 4
    \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! Please edit your existing answers instead of posting new ones. \$\endgroup\$
    – Dennis
    Commented Dec 19, 2017 at 18:42
1
\$\begingroup\$

Excel VBA, 22 Byte

Anonymous VBE immediate window function that takes no input and outputs to the VBE immediate window

?[Rept("Excel VBA",9)]
\$\endgroup\$
1
\$\begingroup\$

C++,  24  22 bytes

Thanks to @Quentin for saving two bytes!

[]{return"C++C++C++";}

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ You can drop the parentheses :) \$\endgroup\$
    – Quentin
    Commented Dec 20, 2017 at 12:20
1
\$\begingroup\$

JavaScript ES7, 30/41/43/33 bytes

Thanks @Shaggy for reducing the size of the second and 4th versions

Boring repeat 10 times: 30 bytes

alert("JavaScript".repeat(10))

Array mapping of a string: 41 bytes

alert([...x="JavaScript"].fill(x).join``)

For loop: 43 bytes

for(i=j='';10>j++;i+="JavaScript");alert(i)

Joining empty 11 element array: 33 bytes

alert(Array(11).join`JavaScript`)

\$\endgroup\$
3
  • \$\begingroup\$ From the spec "Use the common name or acronym of the language." - JS is a common acronym for JavaScript ;) \$\endgroup\$
    – Shaggy
    Commented Dec 18, 2017 at 18:10
  • \$\begingroup\$ Also, your last solution can be 33 bytes: alert(Array(11).join'JavaScript'), replacing single quotes with backticks. \$\endgroup\$
    – Shaggy
    Commented Dec 18, 2017 at 18:12
  • \$\begingroup\$ And your second can be 41 bytes: alert([...x="JavaScript"].fill(x).join''). \$\endgroup\$
    – Shaggy
    Commented Dec 18, 2017 at 18:14
1
\$\begingroup\$

PHP, 27 21 20 bytes

First PHP solution; thanks to everyone who helped out with this. Obviously, I'm not quite ready to start golfing in PHP yet!

<?=str_pad(P,9,HPP);

Try it online

(Yes, <?="PHPPHPPHP"; or just PHPPHPPHP are shorter but they felt far too trivial.)

  • Thanks to Dennis for some tips on PHP, which also saved a byte.
  • Thanks to NieDzejkob for saving a further 5 bytes.
  • Thanks to Titus for saving me a byte and teaching me something new abut PHP.
\$\endgroup\$
13
  • 2
    \$\begingroup\$ This looks longer than just using "PHPPHPPHP" to me. \$\endgroup\$ Commented Dec 17, 2017 at 15:09
  • \$\begingroup\$ @MartinEnder: yeah, but that just felt far too trivial! \$\endgroup\$
    – Shaggy
    Commented Dec 17, 2017 at 15:09
  • 1
    \$\begingroup\$ A trailing semicolon is mandatory in PHP. As a full program <?=str_pad($s="PHP",9,$s); would do. Of course, PHPPHPPHP is a neat 9 byte solution. \$\endgroup\$
    – Dennis
    Commented Dec 17, 2017 at 15:16
  • 1
    \$\begingroup\$ It can be omitted in certain situations, but the closing ?> is already longer. \$\endgroup\$
    – Dennis
    Commented Dec 17, 2017 at 15:22
  • 1
    \$\begingroup\$ <?=str_pad("",9,PHP); for 21 bytes. \$\endgroup\$
    – Maya
    Commented Dec 17, 2017 at 15:46
1
\$\begingroup\$

Perl 6,  14  12 bytes

say 'Perl6'x 5

Try it

{'Perl6'x 5}

Try it (bare block lambda that returns a string)

Note that I have it output Perl6 as Perl 5 and Perl 6 are at least as different as C++ and Java are.

\$\endgroup\$
3
  • \$\begingroup\$ try this {'Perl'x 5} to shave off 3 bytes :) Lambda returns are generally accepted as output. Also the question specifically says that different versions of a language, dosent matter. And since it is code golf, i wouldve used that in my favor ;) \$\endgroup\$ Commented Dec 23, 2017 at 21:53
  • \$\begingroup\$ @HåvardNygård As I stated Perl 5 and Perl 6 are different languages; they are significantly more different than C and C++, and the C++ answer outputs C++C++C++. At least Perl 5 attempts to maintain backwards compatibility with the original Perl from 1987. I have written an example file that combines both Perl 5 and Perl 6, and the code that I have written to make them compatible is larger than the common code. The language is Perl 6, the family of languages is Perl. \$\endgroup\$ Commented Dec 24, 2017 at 14:44
  • \$\begingroup\$ Well, could still return it from the lambda though \$\endgroup\$ Commented Dec 24, 2017 at 15:08
1
\$\begingroup\$

Add++, 11 bytes

L,"Add++"5*

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Swift, 30 bytes

for _ in 1...5{print("Swift")}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Ruby, 10 bytes

p "ruby"*4

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ p"ruby"*4 - you don't need the space. \$\endgroup\$ Commented Dec 19, 2017 at 17:57
0
\$\begingroup\$

Bitwise, 188 bytes

.SUB:
LABEL &1
NOT $1 *1
AND *1 $2 *2
XOR $1 $2 $1
SL *2 &1 $2
JMP @1 $2
RET $1
MOV 1 &7 &1
OUT &66 1
OUT &105 1
OUT &116 1
OUT &119 1
OUT &105 1
OUT &115 1
OUT &101 1
SUB 1 &1 1
JMP &-9 1

Try it online!

I can't golf the .SUB help D:

\$\endgroup\$
0
\$\begingroup\$

Excel Formula, 24

=REPT("ExcelFormula",12)
\$\endgroup\$
0
\$\begingroup\$

C# Interactive, 44 bytes

for(int i=15;--i>0;)Write("C# Interactive");

Haven't found an online compiler, I did it with the C# Interactive REPL in VS 2017.

\$\endgroup\$
0
\$\begingroup\$

shortC, 24 bytes

Da"shortC"
AJa a a a a a

Try it online!

Da"shortC"     // define variable a as string "shortC"
A              // main function
 J             // print string
  a a a a a a  // a, 6 times, auto-concatenated
\$\endgroup\$
0
\$\begingroup\$

Implicit, 16 14 12 bytes

Implicit":+7

Try it online!

Implicit       push character codes for I, m, p, l, i, c, i, t
        "      stringify stack
         :     duplicate top of stack
          +7   concatenate top of stack to previous 7 times
               implicit string output
\$\endgroup\$
0
\$\begingroup\$

Eukleides, 37 bytes

e="Eukleides"
print e,e,e,e,e,e,e,e,e

Don't think it can be golfed down any further. While a list of strings can be printed, they can't be assigned to a variable without a cat operation. So, building a string of three "Eukleides"es and printing three of those blows up to 38 bytes:

e="Eukleides"
f=cat(e,e,e)
print f,f,f

Eukleides prints a newline after every print command. If the challenge allowed for newlines between instances of the language name then we could do this in 33 bytes:

for i=1to 9
print "Eukleides"
end
\$\endgroup\$
0
\$\begingroup\$

VBA, 11 Bytes

Anonymous VBE immediate window function that takes no input and outputs to the VBE immediate window

?"VBAVBAVBA
\$\endgroup\$
0
\$\begingroup\$

LOLCODE, 75 bytes

HAI 1.3
VISIBLE "LOLCODELOLCODELOLCODELOLCODELOLCODELOLCODELOLCODE"
KTHXBYE

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Pushy, 11 bytes

`Pushy\x5`:N"

Where \x5 represents the literal byte 0x05.

Try it online!

`Pushy\x5`      \ Push the character codes for 'Pushy', and a 5
          :     \ Pop the 5 and loop 5 times:
           N"   \ Output the rest of the stack, with no newline.
\$\endgroup\$

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