5
\$\begingroup\$

This question already has an answer here:

Everyone loves The Big Bang Theory, right? And everyone loves polyglots, right? So let's combine them!

Task

Your task in each language is quite basic. You must output the name of the one of the 5 main characters of The Big Bang Theory: Sheldon Lee Cooper, Leonard Leakey Hofstadter, Howard Joel Wolowitz, Rajesh Ramayan Koothrapali and Penny Hofstadter.

Your task overall is to write a polyglot that will work in at least 5 languages. Each language should output a different character on the show.

I say "at least" because in order to win, you must output more characters (see Scoring below). But before that, let's go over the details of your program

Input

You program should take no input when run in any of the languages.

Output

Your program should output the full name of a different characters of TBBT for each language it is run in. If no middle name is known, no middle name is required. 5 of those characters must be the 5 main characters:

  • Leonard Leakey Hofstadter
  • Sheldon Lee Cooper
  • Howard Joel Wolowitz
  • Rajesh Ramayan Koothrapali
  • Penny Hofstadter

The names outputted must be characters that have appeared in more than one episode and they must have both a first and a last name. If they have a middle name, it must be outputted as well.

Scoring

The scoring system is quite basic: your score is the length of your code in bytes minus 20 times the extra number of characters you output. The extra characters are any that aren't in the list above.

length - 20 * (num_characters - 5)

You may also subtract 100 from your score if you don't use any comment characters.

Rules

  • No builtins allowed. (Why not?)
  • The lowest score wins.
  • Only characters with both first and surnames are valid
  • You must output to STDOUT or your languages equivalent. Nothing may be outputted to STDERR
  • Each submission must run in at least 5 different languages
  • Different language versions do not count as different languages
  • Entries must be full programs
  • Case and whitespace matter so an output of Pen nyHof STAdter isn't valid.
  • The valid characters are listed here
  • Leading/trailing whitespace is allowed.
  • A comment character is a character that makes the program ignore the next line or command
\$\endgroup\$

marked as duplicate by Kritixi Lithos, Wheat Wizard, fəˈnɛtɪk, Toto, Mr. Xcoder Apr 13 '17 at 18:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    \$\begingroup\$ I don't think you'll receive answers with more than 5 characters, since adding another character will probably cost multiple bytes, of which only one gets compensated for. I'd suggest a bonus of 20 bytes per extra character. \$\endgroup\$ – Luke Apr 13 '17 at 8:43
  • \$\begingroup\$ @Luke yeah I've edited the question given that I've just wasted 4 hours trying to find a solution for 5 \$\endgroup\$ – caird coinheringaahing Apr 13 '17 at 8:53
  • 9
    \$\begingroup\$ Penny Hofstadter Thanks for the spoiler \$\endgroup\$ – Luis Mendo Apr 13 '17 at 11:43
  • \$\begingroup\$ @ThisGuy That last part isn't necessary (unless there's another meaning to that than the literal meaning) \$\endgroup\$ – HyperNeutrino Apr 13 '17 at 13:27
  • 1
    \$\begingroup\$ "You may also subtract 100 from your score if you don't use any comment characters." Define "comment characters". Does a simple skip statement count as a comment character? The border becomes fuzzy with 2D languages \$\endgroup\$ – Kritixi Lithos Apr 13 '17 at 16:15
1
\$\begingroup\$

Befunge-98, ><>, Haystack, Minkolang, Alice: 5 languages

151 150 146 bytes

4 bytes saved thanks to @MartinEnder

#\"retdatsfoH ynneP">:#,_@>o<'Leonard Leakey Hofstadter'
#>!v"Howard Joel Wolowitz"$O.
| @>"Sheldon Lee Cooper"O
d&O>/"ilaparhtooK nayamaR hsejaR"

All aboard the 2D-language train!

I got the template for this answer from a previous answer of mine from a similar challenge, but I wanted this submission to be composed of only 2D languages. I am planning to add more languages soon.

Befunge-98

Try it online!

#                          Jump over one command
"retdatsfoH ynneP"         Push the characters in this string
>:#,_@                     Print it (basically checks if the top value is not zero, then prints it, otherwise exits the program)

Outputs Penny Hofstadter.

><>

Try it online!

#                         Reflect; the IP moves to the left and wraps around to go to the right edge of the field
'retdatsfo ... ranoeL'    Push the characters in this string
>o<                       And output each character in the stack until there are no more, at which point the program exits with an error

Outputs Leonard Leakey Hofstadter and exits with an error.

Haystack

Try it online!

#                        Ignored
\                        Reflect; moves downward
>                        Move right
!                        Ignored
v                        Go down
>                        Go right
Sheldon Lee Cooper"      Push this string
O                        Output all characters in the stack; the program wraps around to the left edge
|                        End program

Outputs Sheldon Lee Cooper.

Minkolang

Try it online!

#                       Doesn't do anything important
\                       Reflect; moves downward
>                       Move right
!                       Ignore the next command
"Howard Joel Wolowitz"  Push this
$O                      Output all characters in the stack
.                       End program

I could have put the . and the beginning of the second line so that the IP would encounter that once it wraps around, but since the grid is padded with spaces and Minkolang travels through time when it sees a space (infinite loop in this case), I had to include the . right after the $O.

Outputs Howard Joel Wolowitz.

Alice

Try it online!

Alice was the most fun and the most confusing of these languages.

#                     Skip the next command
\                     Mirror; redirect IP north-east
                      The IP gets reflected off the top and start moving south-east instead
!                     This command gets skipped over from the #
>                     Set the horizontal component of the IP to East (changes nothing)
/                     Set the IP's direction to East
"ilaparht ... sejaR"  Push this
                      IP wraps around and comes in from the left edge
d&O                   Output the string (duplicate the output command stack length times)

Now the program goes on a joyride (@MartinEnder showed how this bit works to me) to get to the @ in Row 3, Column 3.

/                     Mirror; redirect IP south-east
                      The IP hits the bottom and reflects north-east

Now the IP moves diagonally up and down as it gets reflected executing the commands along its way.

anJ                   Push 10; negate it into an empty string; and jump to origin (0, 0)
                      After the jump, the IP still moves in a north-easterly (irk) direction
#                     Skip the next command
                      IP gets reflected and start moving south-east
@                     Terminate the program

Of course, the @ could have been placed right after the d&O (replacing the useless >) but that wouldn't have been fun :)

Outputs Rajesh Ramayan Koothrapali.

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

Foo, Python, JavaScript, Retina, ><>: 166 148 bytes

1//1;print('Sheldon Lee Cooper');"""
alert`Howard Joel Wolowitz`

// Rajesh Ramayan Koothrapali
//!??

//\"Leonard Leakey">o<'Penny'" Hofstadter"""

The trailing newline is significant.

Foo outputs Leonard Leakey Hofstadter

Python outputs Sheldon Lee Cooper

JavaScript outputs Howard Joel Wolowitz

Retina outputs Rajesh Ramayan Koothrapali

><> outputs Penny Hofstadter

Explanations

Foo

In Foo, any text written inside double quotes is sent to STDOUT. So it outputs Leonard Leakey and Hofstadter. It also prints it with a leading newline. Honestly I'm really not sure about how it parses strings, but it works as-is. It also tries to do some other operations (/ is divide, parentheses form loops, etc.), but all of that just causes errors and prints to STDERR without affecting the main output in any way.

Python

1//1 is 1 integer divided by 1. In a statement by itself, that does nothing relevant. Then it prints Sheldon Lee Cooper, and the rest is in a triple quoted string, which is basically a block comment.

JavaScript

JavaScript sees most lines as either empty or commented (//). The first statement is 1 by itself which, like in the Python part, does nothing. Then it alerts Howard Joel Wolowitz.

Retina

1//1;print('Sheldon Lee Cooper');"""
alert`Howard Joel Wolowitz`

First all matches of 1//1;print('Sheldon Lee Cooper');""" in the input are replaced with alert`Howard Joel Wolowitz`. Seeing as the input is empty, nothing happens.


// Rajesh Ramayan Koothrapali

Then the empty input is replaced with // Rajesh Ramayan Koothrapali.

//!??

Then all matches of // optionally followed by a ! are replaced with nothing. This deletes the initial //, leaving one leading space (which is allowed).

//\"Leonard Leakey">o<'Penny'" Hofstadter"""

Then all matches of the regex above are replaced with nothing. This regex doesn't match anything in the working string, so nothing happens.

The working string is then output implicitly.

><>

The IP starts in the top-left, initially moving right. It first pushes 1, then bounces around on mirrors (/ and \) for a while (looping around when it goes out of bounds). The 1 will be popped when it hits ?.

Eventually it will be on the right side of the second last line moving left. On this line, it sees an empty string "", pushing nothing. Then it encounters two strings, " Hofstadter" and 'Penny', pushing the characters from each as it sees them. When it hits >o<, it repeatedly pops and prints the top of the stack as a character, until there's nothing left to pop. It exits with an error.

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

Clojure, Java, Ruby, Groovy, Common Lisp - 297 bytes

;/\u002A/
(if '()(print"Leonard Leakey Hofstadter")(eval(quote(princ"Sheldon Lee Cooper"))))
;'then print "Howard Joel Wolowitz" end)
;%(/a*/class I{public static void main(String[]a){System.out.print("${}".getClass().getName().contains("G")?"Rajesh Ramayan Koothrapali":"Penny Hofstadter");}}//%)

Ruby actually sees all the lines of the program. The first line is a ; (no-op) followed by Ruby Regexp. The second line is an if expression which evaluates a string which is True and on the third line it prints the character. The last line is no-op again followed by multi-line string %( and %).

See it online : Ruby

Java and Groovy see the same portion of the program, these langauges allow ; as no-op (first line), then the comment is started as /\u0002A which evaluates to /* and then the comment ends right before class declaration. After that it's a plain Java/Groovy program. In order to distinguish between them I check the name of the String object class, in Java it will be the usual java.lang.String but in Groovy this string object will have class name groovy.lang.GString because it contains interpolated expression ${}.

See it online: Java , Groovy

Clojure and Common Lisp see only the second line of the program (; denotes comment). In Clojure empty list '() (quote symbol luckily denotes string in ruby) evaluates to true and it evaluates to nil in Common Lisp, which is false. eval has to be used in an else part because print in Common Lisp outputs value with double-quotes so princ is used which is not a valid function in Clojure so it's eval`d.

See it online: Clojure , Common Lisp

\$\endgroup\$

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