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

closed as unclear what you're asking by FlipTack, TanMath, Rɪᴋᴇʀ, Sriotchilism O'Zaic, 0 ' Dec 26 '17 at 15:42

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 30
    \$\begingroup\$ Tasks that depend on a language's name are a form of disadvantaging some languages by arbitrary criteria. \$\endgroup\$ – Martin Ender Dec 17 '17 at 15:08
  • 16
    \$\begingroup\$ I think this challenge would have been a lot more interesting if the repetition count was supposed to be our bytecount... \$\endgroup\$ – NieDzejkob Dec 17 '17 at 16:53
  • 14
    \$\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 Dec 17 '17 at 21:06
  • 3
    \$\begingroup\$ @DonielF is that shortest though? \$\endgroup\$ – Quintec Dec 18 '17 at 20:09
  • 3
    \$\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 Dec 24 '17 at 19:25

97 Answers 97

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\$
  • \$\begingroup\$ you can use apply str instead of clojure.string/join ? \$\endgroup\$ – cliffroot Dec 18 '17 at 9:36
  • \$\begingroup\$ @cliffroot nice trick. thanks! \$\endgroup\$ – Uriel Dec 18 '17 at 10:40
1
\$\begingroup\$

PHP (9 bytes)

PHPPHPPHP

Try it online

\$\endgroup\$
  • 2
    \$\begingroup\$ Hah. can't believe str_repeat(3,'PHP') is the long alternative. \$\endgroup\$ – Magic Octopus Urn Dec 19 '17 at 14:55
  • 1
    \$\begingroup\$ Excuse my brevity with this answer; it's hardly a difficult challenge and by the questions posed above, it's apparently a perfectly legal one as well. \$\endgroup\$ – Shaun Bebbers Dec 19 '17 at 17:19
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\$
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
    \$\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 Dec 18 '17 at 19:37
1
\$\begingroup\$

Scala 27 16 bytes

print("Scala"*5)
\$\endgroup\$
  • \$\begingroup\$ I don't know Scala, but would assigning it to a variable be shorter than writing it twice? \$\endgroup\$ – Connor Bell Dec 19 '17 at 14:37
  • \$\begingroup\$ or just using 5 instead of "Scala".size \$\endgroup\$ – Giuseppe Dec 19 '17 at 14:40
  • \$\begingroup\$ Assigning to a variable takes 29 bytes unfortunately. And yes @Giuseppe I'm dumb.... \$\endgroup\$ – AmazingDreams Dec 19 '17 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\$
  • 4
    \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! Please edit your existing answers instead of posting new ones. \$\endgroup\$ – Dennis Dec 19 '17 at 18:42
1
\$\begingroup\$

C++,  24  22 bytes

Thanks to @Quentin for saving two bytes!

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

Try it online!

\$\endgroup\$
  • \$\begingroup\$ You can drop the parentheses :) \$\endgroup\$ – Quentin Dec 20 '17 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\$
  • \$\begingroup\$ From the spec "Use the common name or acronym of the language." - JS is a common acronym for JavaScript ;) \$\endgroup\$ – Shaggy Dec 18 '17 at 18:10
  • \$\begingroup\$ Also, your last solution can be 33 bytes: alert(Array(11).join'JavaScript'), replacing single quotes with backticks. \$\endgroup\$ – Shaggy Dec 18 '17 at 18:12
  • \$\begingroup\$ And your second can be 41 bytes: alert([...x="JavaScript"].fill(x).join''). \$\endgroup\$ – Shaggy Dec 18 '17 at 18:14
1
\$\begingroup\$

Sinclair ZX81/Timex TS1000/1500 BASIC, ~33 tokenized BASIC bytes for the listing

 LET A$="BASIC"
 1 FOR I=SGN PI TO LEN A$
 2 PRINT A$;
 3 NEXT I

Enter the language name into the var stack using direct mode to save one BASIC line, and save bytes in the listing itself. I assume the A$ variable is five bytes for the string and two bytes for the pointer, but I'm not 100% sure how the this works on the ZX81 - I will find out and update the byte count.

Sinclair ZX81/Timex TS1000/1500 BASIC (non-dynamic solution) ~21 tokenized BASIC bytes (symbolic listing)

 LET A$="BASIC"
 1 PRINT A$;A$;A$;A$;A$

Using the same technique as above, entering the A$ variable in direct mode and then simply printing the string five times. To run either solution, don't use the command RUN or the var stack is initialised. Use:

 GOTO 1
\$\endgroup\$
  • 1
    \$\begingroup\$ Save 5 bytes by using SGN PI instead of 1. And by my count the second one is only 36 bytes. \$\endgroup\$ – Neil Dec 18 '17 at 11:23
  • \$\begingroup\$ Yes, I will optimise futher; also one could use INPUT A$ in line one, and will therefore work with any language inputted into the A$ string \$\endgroup\$ – Shaun Bebbers Dec 18 '17 at 11:25
  • \$\begingroup\$ @Neil - how are you counting 36 bytes in the second listing? \$\endgroup\$ – Shaun Bebbers Dec 19 '17 at 14:24
  • \$\begingroup\$ The first line is 4 bytes for the line number and length, 1 for the token, 10 normal bytes, 1 for the newline. The second is similar, except it has 14 normal bytes. I make that 36 bytes in total. \$\endgroup\$ – Neil Dec 19 '17 at 16:43
  • \$\begingroup\$ It's a good job I put a ~ in front of my byte count isn't it. Somehow I mis-counted. Twice. But I'd rather work out proper byte counts on 8 bit machines, i.e., how much actual memories do my listings take? \$\endgroup\$ – Shaun Bebbers Dec 19 '17 at 17:21
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\$
  • 2
    \$\begingroup\$ This looks longer than just using "PHPPHPPHP" to me. \$\endgroup\$ – Martin Ender Dec 17 '17 at 15:09
  • \$\begingroup\$ @MartinEnder: yeah, but that just felt far too trivial! \$\endgroup\$ – Shaggy Dec 17 '17 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 Dec 17 '17 at 15:16
  • 1
    \$\begingroup\$ It can be omitted in certain situations, but the closing ?> is already longer. \$\endgroup\$ – Dennis Dec 17 '17 at 15:22
  • 1
    \$\begingroup\$ <?=str_pad("",9,PHP); for 21 bytes. \$\endgroup\$ – NieDzejkob Dec 17 '17 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\$
  • \$\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\$ – Håvard Nygård Dec 23 '17 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\$ – Brad Gilbert b2gills Dec 24 '17 at 14:44
  • \$\begingroup\$ Well, could still return it from the lambda though \$\endgroup\$ – Håvard Nygård Dec 24 '17 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
    \$\begingroup\$ p"ruby"*4 - you don't need the space. \$\endgroup\$ – Magic Octopus Urn Dec 19 '17 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\$

C, 20 bytes

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

Try it online!

\$\endgroup\$
  • 3
    \$\begingroup\$ You can save a few bytes by using puts instead \$\endgroup\$ – Conor O'Brien Dec 18 '17 at 3:53
  • \$\begingroup\$ And even more by making it a function, f(){puts("C");} \$\endgroup\$ – MD XF Dec 26 '17 at 22:15
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\$

Julia, 24 bytes

print(repeat("Julia",5))

Try it online!

\$\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\$
0
\$\begingroup\$

Underload, 28 bytes

(Underload)::::::::********S

Try it online!

\$\endgroup\$

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