Palindrome Hello, World

29

1

Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right to left the same as in left to right. Standard loopholes are NOT allowed.

user45510

Posted 2015-10-03T13:55:39.380

Reputation:

This does not seem to be "hello world". – Erik the Outgolfer – 2016-05-18T13:43:29.597

4@ΈρικΚωνσταντόπουλος It's the same as Hello World for all intents and purposes. The goal is to print a short string consisting of two words with the punctuation common in Hello World programs as well. Apart from built-ins that print Hello World, solutions will be absolutely identical (apart from the actual string) regardless of the actual string being printed. (And I assume the phrase "Greetings, Planet!" was chosen specifically to make built-ins useless.) – Martin Ender – 2016-05-18T13:52:00.520

1@MartinBüttner I think that Hello, world! and Hello World! are the only outputs allowed for a [tag:hello-world] program. – Erik the Outgolfer – 2016-05-18T14:09:48.387

Answers

33

///, 37 bytes

Greetings, Planet!/!tenalP ,sgniteerG

Dennis

Posted 2015-10-03T13:55:39.380

Reputation: 196 637

10This is gonna be tough to beat. – PhiNotPi – 2015-10-03T15:06:24.393

16

TI-BASIC, 67 bytes

"!tenalP ,sgniteerG"
"Greetings, Planet!"

This works because the last line of a program is displayed on the screen, while the first string is essentially treated as a comment.

Each lowercase letter is stored as 2 bytes, and the remaining characters are 1 byte. If I were to bend the rules and print in all caps, it would be 41 bytes:

"!TENALP ,SGNITEERG"
"GREETINGS, PLANET!"

NinjaBearMonkey

Posted 2015-10-03T13:55:39.380

Reputation: 9 925

Can you use e and i (the numbers) to reduce byte count further? – Addison Crump – 2015-10-17T21:37:45.680

1@VTCAKAVSMoACE I considered that, but they italicized, so they look,slightly different. – NinjaBearMonkey – 2015-10-18T02:27:14.940

To be clear the first line isn't a comment, it gets stored to the answer variable. – Julian Lachniet – 2016-12-29T15:29:27.283

13

I know this is a bit late (and a bit finicky), but...

><> (Fish), 47 45 47 Bytes (really 43 45, if I wasn't using the randomized direction)

x"!tenalP ,sgniteerG"!|o|!"Greetings, Planet!"x

These answers are a bit different to every other; there is a chance for either direction of code to be executed.

So, by "printing to console", I assumed you meant printing to stdout. This throws an error; the error is thrown to stderr AFTER the string is printed to stdout.

To prove that this worked both ways, I used the "random direction" director, "x". Fish is a two-dimensional language, so, no matter which way the director points, the code will still (eventually) be executed.

Assuming that the first director points to the right, the characters are loaded to the "stack" in reverse order, then the reverse of the reverse (or the normal text) is printed.

Assuming that both directors point to the left, the characters are, once again, loaded to the "stack" in reverse order (because the code loads it in backwards here, direction is to the left), then the reverse of the reverse (or the normal text) is printed.

If the randomized director points up or down, this won't matter - fish knows to loop to the underside or overside of the code, pointing back to the randomizer. In this way, it will continue to loop with the randomizers until it points inward, towards the code to execute.

The !|o|! bit does the following, from both sides:

  • ! skips the next instruction (will always skip |)

  • | is a reflector; it points inward back towards o.

  • o outputs the current item of the stack to console as a character and removes it from the stack.

So, essentially, this is the "two mirrors in a bathroom pressed up together" trick, where I output until I can't anymore.

Now using a cat emoji. >o< redirects the output inward infinitely, still throwing the error, but I can get away with not using a skip into reflection.

Turns out I was right the first time - the second attempt was not palindromic, but it was reflective.

Fish (without printing to stderr), 64 Bytes (ew)

x"!tenalP ,sgniteerG"!;oooooooooooooooooo;!"Greetings, Planet!"x

This dude's a little longer.

It has the same randomized arrow function (to prove it works both ways) and does not print to stderr.

The difference here is obvious; I literally print out every item in the stack, then end execution with ;.

The !; does not end execution immediately, as ! skips the next item (end exec, in this case) and continues until it hits the other side, which acts as ;!, wherein it ends execution before it skips anything.

It follows the same randomized direction pattern as the shorter answer.

Addison Crump

Posted 2015-10-03T13:55:39.380

Reputation: 10 763

I think you should call the language ><> to distinguish it from the Fish shell

– Aaron – 2015-12-07T14:57:00.747

@Aaron It is generally assumed that Fish here means ><>, but I've encountered that problem before - I'll add it. Thanks! – Addison Crump – 2015-12-07T20:10:55.547

as i guess , it's unpridictable wheather the full code will be excuted or not . What if program counter is stuck between two random direction instructions , or just stuck at one of the random direction instructions , for example , it turns down , reachs the bottom , comes back to that instruction and start all over ? – None – 2016-07-13T17:11:15.217

@GLASSIC The program will only output once, and the entire code will never be executed. – Addison Crump – 2016-07-14T03:18:41.447

11

Bubblegum, 38 bytes

0000000: 73 2f 4a 4d 2d c9 cc 4b 2f d6 51 08 c8 49 cc 4b 2d 51 04  s/JM-..K/.Q..I.K-Q.
0000013: 04 51 2d 4b cc 49 c8 08 51 d6 2f 4b cc c9 2d 4d 4a 2f 73  .Q-K.I..Q./K..-MJ/s

Dennis

Posted 2015-10-03T13:55:39.380

Reputation: 196 637

10

Macaroni 0.0.2, 52 bytes

print "Greetings, Planet!""!tenalP ,sgniteerG" tnirp

A solution that doesn't use comments. (Mostly because Macaroni doesn't have comments...)

Doorknob

Posted 2015-10-03T13:55:39.380

Reputation: 68 138

15Macaroni doesn't have comments? ಠ_ಠ – Alex A. – 2015-10-03T18:16:42.327

8

CJam, 41 bytes

Thanks to Dennis for the three bytes off.

"!tenalP ,sgniteerG";"Greetings, Planet!"

The_Basset_Hound

Posted 2015-10-03T13:55:39.380

Reputation: 1 566

2You need to flip the strings. Right now you're popping the right output and printing the reversed one. – NinjaBearMonkey – 2015-10-03T15:14:54.620

@NinjaBearMonkey Whoops. Fixing. – The_Basset_Hound – 2015-10-03T15:16:21.683

Also works in GolfScript. – Ilmari Karonen – 2015-12-04T20:54:25.600

7

Foo, 39 bytes

"Greetings, Planet!"!tenalP ,sgniteerG"

Try it online.

a spaghetto

Posted 2015-10-03T13:55:39.380

Reputation: 10 647

!tenalP ,sgniteerG"Greetings, Planet! saves a few bytes. – Dennis – 2017-04-24T20:17:31.987

6

JavaScript, 56 bytes

This can run in any browser.

alert("Greetings, Planet!")//)"!tenalP ,sgniteerG"(trela

Downgoat

Posted 2015-10-03T13:55:39.380

Reputation: 27 116

Replacing print/tnirp with alert/trela, it works in other engines, too. – ETHproductions – 2015-12-04T19:04:31.803

@ETHproductions can't believe I didn't think of that, thanks! – Downgoat – 2015-12-05T02:09:51.517

2Template Strings? demo – jrich – 2015-12-07T21:16:16.447

@jrich your're right, alert\Greetings, Planet!`//`!tenalP ,sgniteerG`trela` is 52 bytes – Aᴄʜᴇʀᴏɴғᴀɪʟ – 2016-02-18T03:51:15.817

5

GolfScript, 41 bytes

"Greetings, Planet!":"!tenalP ,sgniteerG"

Look ma, no no-ops! Try it online in Web GolfScript.

The second half of the source code stores the string in the second string.

"Greetings, Planet!":"!tenalP ,sgniteerG"
"!tenalP ,sgniteerG"

would print

Greetings, Planet!Greetings, Planet!

Dennis

Posted 2015-10-03T13:55:39.380

Reputation: 196 637

5

C++, 129 bytes

Trying to do this without comments led me into a deep, dark preprocessor nightmare with no way out that I could see. Instead I've just aimed to get it as short as possible.

/**/
#include<cstdio>
int main(){puts("Greetings Planet!");}//*/
/*//};)"!tenalP sgniteerG"(stup{)(niam tni
>oidtsc<edulcni#
/**/

Luke

Posted 2015-10-03T13:55:39.380

Reputation: 5 091

5

Python 3, 57 bytes

print('Greetings, Planet!')#)'!tenalP ,sgniteerG'(tnirp

I fixed the issue with parenthesis.

Python 2, 53 bytes

print'Greetings, Planet!'#'!tenalP ,sgniteerG'tnirp

I used advantage of the lack of required parenthesis and spaces in Python 2, but there wasn't that big of a difference.

Noomann

Posted 2015-10-03T13:55:39.380

Reputation: 61

5

Jelly, non-competing

25 bytes This answer is non-competing, since the challenge predates the creation of Jelly.

»1ị“RsẈḄ,#ʠU“Uʠ#,ḄẈsR“ị1»

Look 'ma, no comments! Try it online!

How it works

»1ị“RsẈḄ,#ʠU“Uʠ#,ḄẈsR“ị1»  Main link. No arguments.

   “        “        “  »  Decompress all three strings; yield a list of strings.
    RsẈḄ,#ʠU               (decompresses to 'Greetings, Planet!')
             Uʠ#,ḄẈsR      (decompresses to ' WafdkmC Posited,')
                      ị1   (decompresses to 'Taarhus')

»1                         Take the maximum of the default argument (0) and 1.
  ị                        Select the string at the index to the left.

Dennis

Posted 2015-10-03T13:55:39.380

Reputation: 196 637

4

Stuck, 41 Bytes

"Greetings, Planet!"p"!tenalP ,sgniteerG"

Fairly similar to the CJam answer, except in Stuck if a print command is issued, automatic stack printing is suppressed.

Kade

Posted 2015-10-03T13:55:39.380

Reputation: 7 463

3

Mathematica, 52 bytes

Print@"Greetings, Planet!""!tenalP ,sgniteerG"@tnirP

Also generates a Null "!tenalP ,sgniteerG"[tnirP] which doesn't get printed.

LegionMammal978

Posted 2015-10-03T13:55:39.380

Reputation: 15 731

1FYI, a lot of your answers (this one included) have been getting tossed in the Low Quality queue because they're solely a title/score and code. Though there's nothing wrong with that, you may consider adding more text (such as an explanation) so they don't get auto-flagged. – Mego – 2015-11-29T02:57:59.860

@Mego Okay, thought they were pretty self-explanatory. – LegionMammal978 – 2015-11-29T11:14:07.493

1I'm not saying the lack of an explanation is a bad thing (though answers with explanations tend to get more upvotes), I'm just letting you know that your (valid) answers were getting auto-flagged because of their length. :) – Mego – 2015-11-30T09:12:15.157

2you can save 2 bytes with Echo in v10.3. – shrx – 2015-12-07T13:46:38.320

3

Fission, 45 43 bytes

Thanks to jimmy23013 for saving 2 bytes.

;"!tenalP ,sgniteerG"R"Greetings, Planet!";

Try it online!

R initialises an atom which moves to the right. " toggles string mode which simply prints the desired string to STDOUT before hitting ;, which destroys the atom and terminates the program. The first half is simply never executed.

Martin Ender

Posted 2015-10-03T13:55:39.380

Reputation: 184 808

@jimmy23013 I have no clue, to be honest. Thanks. – Martin Ender – 2016-05-18T13:47:56.677

3

05AB1E, 16 bytes

Code:

”!º¥,ÁÙ””ÙÁ,¥º!”

Explanation:

”!º¥,ÁÙ”          # Compressed string which results in "! Crm, Everywhere".
        ”ÙÁ,¥º!”  # Compressed string which results in "Greetings, Planet!".
                  # Top of stack is implicitly outputted.

Try it online!

Adnan

Posted 2015-10-03T13:55:39.380

Reputation: 41 965

2

TCL, 80 Bytes

proc unknown args {puts "Hello World!"}
}"!dlroW olleH" stup{ sgra nwonknu corp

explanation: TCL executes a global proc unknown when it encounters a call to an undefined command, the first line redefines that proc to a simple "hello world" program.

TCL's quoting rules are quite subtle, an open brace starts a quoted word that extends to the next matching close brace, allowing nested, quoted words. Braces are otherwise treated as normal characters. five words: }"!dlroW olleH", stup{, sgra, nwonknu and corp. No command named }"!dlroW olleH" has been defined, so the undefined proc from the first line is invoked instead.

A similar question was posted on the StackOverflow of antiquity; which has since been closed and deleted. I used my solution as a tongue in cheek TCL sample in this answer, and am now getting comments asking for an explanation, so I recreate my answer here.

SingleNegationElimination

Posted 2015-10-03T13:55:39.380

Reputation: 121

2

Keg, 41 bytes

Greetings\, Planet\!#!\tenalP ,\sgniteerG

Try it online!

user85052

Posted 2015-10-03T13:55:39.380

Reputation:

Try it online! – Lyxal – 2019-08-09T23:05:41.687

2

STATA, 52 bytes

di "Greetings, Planet!"//"!tenalP ,sgniteerG" id

A slightly longer (53 byte) version that doesn't use comments is:

#d
di "Greetings, Planet!";"!tenalP ,sgniteerG" id
d#

#d [something] changes the delimiter (initially a carriage return) to ; unless [something] is cr, so the first command changes the delimiter to ;, the second prints the string, and the third (which continues until the end) is apparently a nop, though I have no idea why. I would have guessed that this would throw an error (unrecognized command "!tenalP ,sgniteerG" or something), but apparently not.

bmarks

Posted 2015-10-03T13:55:39.380

Reputation: 2 114

2

Japt, 29 bytes

This programming language was made after the question was posted, but was not made for this question.

`!t?ÓP ,?Ä>ÎG`;`GÎ>Ä?, PÓ?t!`

Try it online!

Each ? is an unprintable Unicode char: U+0082, U+000F, U+000F, and U+0082, respectively.

Fun fact: If Japt had been published a month sooner, it would have legitimately won this challenge.

ETHproductions

Posted 2015-10-03T13:55:39.380

Reputation: 47 880

2

APL, 41 bytes

'Greetings, Planet!'⍝'!tenalP ,sgniteerG'

In APL, the last value is printed and the lamp character (⍝) start a comment.

TuxCrafting

Posted 2015-10-03T13:55:39.380

Reputation: 4 547

Hello, and welcome to PPCG! Great answer! – NoOneIsHere – 2016-05-28T20:20:51.803

2

GolfScript, 41 bytes

"Greetings, Planet!"#"!tenalP ,sgniteerG"

Try it online !

Lordmusic Player

Posted 2015-10-03T13:55:39.380

Reputation: 21

@muddyfish Edited. Now it is a palindrome . Sorry. – Lordmusic Player – 2016-05-31T20:19:51.693

1

Ruby, 43 bytes

p"Greetings, Planet!"#"!tenalP ,sgniteerG"p

CocoaBean

Posted 2015-10-03T13:55:39.380

Reputation: 309

1

Lua, 52 Bytes

print"Greetings, Planet!"--"!tenalP ,sgniteerG"tnirp

In Lua terminal, it is only 44 bytes with

="Greetings, Planet!"--"!tenalP ,sgniteerG"=

Digital Veer

Posted 2015-10-03T13:55:39.380

Reputation: 241

My bad. Thanks for the alert! – Digital Veer – 2015-11-29T02:30:32.780

Remove all parentheses. For functions with a single string parameter they are optional. – manatwork – 2015-12-05T11:13:20.567

Lua 5.3 do not require = in terminal, so it is 2 bytes off there. I think it existed in 2015, not sure tho. – val says Reinstate Monica – 2019-08-17T19:19:15.587

1

Vitsy, 41 Bytes

This programming language was made after the question was posted, but was not made for this question.

"!tenalP ,sgniteerG"Z"Greetings, Planet!"

The Z character outputs everything in the stack to STDOUT.

Try it online!

Addison Crump

Posted 2015-10-03T13:55:39.380

Reputation: 10 763

1

Unefunge 98 - 49 bytes

"!tenalP ,sgniteerG<DC1>"k,@,k"<DC1>Greetings, Planet!"

The code above contains two unprintable characters with code 17 (device control 1) represented by <DC1>.

pppery

Posted 2015-10-03T13:55:39.380

Reputation: 3 987

1

MSM, 73 bytes

GGreetings, Planet!.................,.................!tenalP ,sgniteerGG

The first half just before the middle , builds a reverse greeting string including the additional G on the very right. The middle , drops it and the rest is a canonical "Hello/Greeting/whatever" program. The additional characters on both ends are needed, because the message contains a ,. The left one is executed and drops the s. Both , and s need a replacement for the left concatenation dots, hence the Gs. The , on the right isn't executed, but build into the final string.

nimi

Posted 2015-10-03T13:55:39.380

Reputation: 34 639

1

Bash, 52 48 bytes

echo Greetings, Planet!||!tenalP ,sgniteerG ohce

Also works in ksh, zsh, yash, dash. But not tcsh.

$ cat x.sh
echo Greetings, Planet!||!tenalP ,sgniteerG ohce
$ bash x.sh
Greetings, Planet!
$ ksh x.sh
Greetings, Planet!
$ zsh x.sh
Greetings, Planet!
$ yash x.sh
Greetings, Planet!
$ dash x.sh
Greetings, Planet!
$ tcsh x.sh
tenalP: Event not found.
$

steve

Posted 2015-10-03T13:55:39.380

Reputation: 2 276

1Remove all quotes. – manatwork – 2015-12-05T11:17:44.487

1Oh dear, a bash answer was shorter than python =/. Back to the drawing board! – Ashwin Gupta – 2015-12-07T17:22:49.360

1

CoffeeScript, 53 bytes

Similar to Ruby and Lua and pretty much all the variants here.

alert 'Greetings, Planet!'#'!tenalP ,sgniteerG' trela

rink.attendant.6

Posted 2015-10-03T13:55:39.380

Reputation: 2 776

1

Milky Way 1.5.10, 43 41 39 bytes

"Greetings, Planet!"!tenalP ,sgniteerG"

Explanation

"Greetings, Planet!"                       # push the string to the stack
                    !                      # output the TOS
                     tenalP ,sgniteerG"    # throws an error and exits

Usage

python3 milkyway.py <path-to-code>

Zach Gates

Posted 2015-10-03T13:55:39.380

Reputation: 6 152

Did you really need a comment? If this is stack based (without implicit output), then just outputting the stack should work. – Addison Crump – 2015-12-07T20:15:15.240

You're right! Thanks. @FlagAsSpam – Zach Gates – 2015-12-07T20:25:09.690

1

jq, 44 characters

(42 charactes code + 2 character command line option.)

"Greetings, Planet!"//"!tenalP ,sgniteerG"

(Not a big deal, posted just for the sake of that operator. Yes, // is not comment, is the alternative operator: if its left operand is null or false, the right operand is returned, otherwise the left operand.)

Sample run:

bash-4.3$ jq -nr '"Greetings, Planet!"//"!tenalP ,sgniteerG"'
Greetings, Planet!

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)

manatwork

Posted 2015-10-03T13:55:39.380

Reputation: 17 865

1

Emacs Lisp, 60 bytes

(message"Greetings, planet!");)"!tenalp , sgniteerG"egassem(

As you might have already guessed ; denotes a comment.

Lord Yuuma

Posted 2015-10-03T13:55:39.380

Reputation: 587

There you have some characters images reversed instead of character orders. For example if the first character is (, the last one must also be (. (See Downgoat's JavaScript answer as example.)

– manatwork – 2015-12-15T20:54:51.537

1

Fishing, Dock length 41

v+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  `Greetings, Planet!`P`!tenalp ,sgniteerG`

For a palindrome that also includes the dock and is measured in total bytes, this has 132 bytes.

v+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  `Greetings, Planet!`P`!tenalp ,sgniteerG`  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC+v

Fishing prints the stack with P. Because the dock ends at the end of the first line, no other fish are caught or executed.

Arcturus

Posted 2015-10-03T13:55:39.380

Reputation: 6 537

1

Golfscript, 41 bytes

"!tenalP ,sgniteerG";"Greetings, Planet!"

Pushes "!tenalP ,sgniteerG" to stack, removes top of stack (;), and pushes "Greetings, Planet!". Stack is printed at end of execution in GolfScript.

NoOneIsHere

Posted 2015-10-03T13:55:39.380

Reputation: 1 916

1

Self-Modifying Brainf*ck, 67 bytes

+[<[<]<[.<]-][0Greetings, Planet!0!tenalP ,sgniteerG0][-[>.]>[>]>]+

Where the 0's denote null characters.

The first <[<] moves the pointer to the beginning of the message (the last null character) And the following <[,<] reads and outputs the message until the terminating null character. This is a pretty long answer, so it probably won't stand a chance, but hey, it's pretty cool.

takra

Posted 2015-10-03T13:55:39.380

Reputation: 793

1

Fuzzy Octo Guacamole, 52 bytes

(non-competing, FOG is newer than the challenge)

'Greetings, Planet!'X@X'!tenalP ,sgniteerG'

Pushes "Greetings, Planet!" to the stack, pop, print, and end. ('' pushes the string, _; pops and prints, and @ terminates immediately.

Without the @, it would then print 0 after the string.

Rɪᴋᴇʀ

Posted 2015-10-03T13:55:39.380

Reputation: 7 410

1

C, 72 bytes

main(){puts("Greetings, Planet!");}//};)"!tenalP ,sgniteerG"(stup{)(niam

mIllIbyte

Posted 2015-10-03T13:55:39.380

Reputation: 1 129

1

Self-modifying Brainfuck, 47 bytes

Greetings, Planet!<[.<]<.[<!tenalP ,sgniteerG

The code contains two null-bytes, shown here as 0:

Greetings, Planet0!<[.<]<.[<!0tenalP ,sgniteerG

Try it online!

Explanation

Like the other SMBF answers, this includes the required string in the source code, along with a null-byte as an end-of-string marker. Note that SMBF is like regular BF, except that the source is copied to the front of the tape and the tape head starts at the cell just after the source code.

We can save some bytes over the other answers by putting the actual string at the end, so that we don't have to skip past the actual source code. Finally, we can save one more byte by putting the ! on the other side of the null-byte which conveniently lets us reuse the <. in the mirror image to print the last character (otherwise we'd have to double the ] to avoid that <. is executed). Here is the code:

,     Read a character, which is a no-op with no input.
<     Move tape head onto the 'G'.
[.<]  In a loop, print character, move tape head left. This prints the desired
      string except for the '!'. The loop terminates when the tape head reaches
      the null byte.
<     Move the tape head left another cell onto the '!'. 
.     Print it.
[     Unmatched square bracket, terminates the program.

Martin Ender

Posted 2015-10-03T13:55:39.380

Reputation: 184 808

1

Hoon, 41 bytes

"Greetings, Planet!":"!tenalP ,sgniteerG"

In Hoon, a:b means "compute a in the context of b". To include a library, for example, you stick a rune that evaluates the rest of your program in the context of the core containing the library. This is possible because cores also contain the entire kernel and stdlib, so you can nest them and still compute.

Because a string literal is just a constant expression that doesn't depend on the context it is being evaluated in at all, we can replace the entire stdlib with just another constant expression and it will evaluate to the same thing.

RenderSettings

Posted 2015-10-03T13:55:39.380

Reputation: 620

1

Brachylog, 41 bytes (non-competing)

"Greetings, Planet!"w"!tenalP ,sgniteerG"

This will call w - write with "Greetings, Planet!" as input and "!tenalP ,sgniteerG" as output. w writes its input to STDOUT and does nothing with its output.

Fatalize

Posted 2015-10-03T13:55:39.380

Reputation: 32 976

1

Pyth, 41 bytes

"Greetings, Planet!"K"!tenalP ,sgniteerG"

Prints "Greetings, Planet!", then assigns "!tenalP ,sgniteerG" to K

acrolith

Posted 2015-10-03T13:55:39.380

Reputation: 3 728

1

PowerShell, 41 bytes

"Greetings, Planet!"#"!tenalP ,sgniteerG"

Output is implied is PowerShell and anything after # is a comment.

ThePoShWolf

Posted 2015-10-03T13:55:39.380

Reputation: 171

1

R, 51 bytes

cat("Greetings, Planet!")#("!tenalP ,sgniteerG")tac

No really original, # indicates a commentary in R

Frédéric

Posted 2015-10-03T13:55:39.380

Reputation: 2 059

The reversed version is )"!tenalP ,sgniteerG"(tac, not ("!tenalP ,sgniteerG")tac – TuxCrafting – 2016-10-07T13:50:57.747

1

Hy, 58 bytes

(print "Greetings, Planet!");;("!tenalP ,sgniteerG" tnirp)

I'm not competing.

XiKuuKy

Posted 2015-10-03T13:55:39.380

Reputation: 369

0

AWK, 66 bytes

BEGIN{print"Greetings, Planet!"#"!tenalP, sgniteerG"tnirp{NIGEB

Could save some bytes if input were allowed, but I assume it isn't.

The input required code would save 15 bytes and be run like this:

awk '{$0="Greetings, Planet!"}1#1{"!tenalP, sgniteerG"{' <<< "arbitrary string here"

Robert Benson

Posted 2015-10-03T13:55:39.380

Reputation: 1 339

0

q/kdb+ 41 bytes

Solution:

"!tenalP ,sgniteerG";"Greetings, Planet!"

Example:

q)"!tenalP ,sgniteerG";"Greetings, Planet!"
"Greetings, Planet!"

Explanation:

This is really just two statements separated by a semicolon, "!tenalP ,sgniteerG" and "Greetings, Planet!", due to the ;, the first statement does not get printed to the console.

streetster

Posted 2015-10-03T13:55:39.380

Reputation: 3 635

0

Underload, 48 bytes

)(Greetings, Planet!)S())(S)!tenalP ,sgniteerG()

Uses the fact that non-matching closing brackets don't error on the interpreter that TIO uses.

How it works

) Used to make a matching pair of brackets at the end, so it doesn't error
(Greetings, Planet!)S   Outputs 'Greetings, Planet!'
()   Used to make it so the output command doesn't run a second time, since it gets enclosed in bracket. Also, adds an element to the stack so the 'a' in the '!tenalP, sgniteerG', doesn't error, since 'a' is a command in Underload
)(S)   Pushes S to the stack
!tenalP ,sgniteerG   Reversed 'Greetings, Planet'. Every character is a no-op apart from 'a'
()   Matching pair of brackets I mentioned on the first line

Try it Online!

EdgyNerd

Posted 2015-10-03T13:55:39.380

Reputation: 1 106

0

Java, 192 Bytes

public class C{public static void main(String[] args){System.out.print("Greetings, Planet!");}}//}};)"!tenalP ,sgniteerG"(tnirp.tuo.metsyS{)sgra ][gnirtS(niam diov citats cilbup{C ssalc cilbup

For the online compiler i had to change the class name from C to Main

Try it online!

René

Posted 2015-10-03T13:55:39.380

Reputation: 1

In what Java compiler does this work as-is, without changing C to Main? – mbomb007 – 2019-08-01T14:45:14.777

this is necessary for the online compiler but i dont know why – René – 2019-08-01T15:07:21.400

Does it work in an offline compiler? – mbomb007 – 2019-08-01T15:59:53.303

yeah of cause it does – René – 2019-08-01T16:05:13.837

0

T-SQL, 52 bytes

PRINT'Greetings, Planet!'--'!tenalP ,sgniteerG'TNIRP

Not much different from other answers, but didn't see another SQL-based solution.

-- is an in-line comment in T-SQL, PRINT is one byte shorter than SELECT.

BradC

Posted 2015-10-03T13:55:39.380

Reputation: 6 099

0

Pip, 42 40 bytes

"!tenalP ,sgniteerG""Greetings, Planet!"

Try it online!

Pip prints the last expression in a file

Kenneth Taylor

Posted 2015-10-03T13:55:39.380

Reputation: 183

0

Julia (1.2), 41 bytes

"!tenalP ,sgniteerG";"Greetings, Planet!"

Example

julia> print("!tenalP ,sgniteerG";"Greetings, Planet!")
"Greetings, Planet!"

Explanation

Putting a semicolon on the end of an expression makes the expression not output anything.

Sagittarius

Posted 2015-10-03T13:55:39.380

Reputation: 169

0

ink, 38 bytes

Greetings, Planet!//!tenalP ,sgniteerG

Try it online!

Sara J

Posted 2015-10-03T13:55:39.380

Reputation: 2 576

0

Dyalog APL, 43 bytes

'!tenalP ,sgniteerG'∘⊢∘'Greetings, Planet!'

or

'Greetings, Planet!'∘⊣∘'!tenalP ,sgniteerG'

Adám

Posted 2015-10-03T13:55:39.380

Reputation: 37 779

Really cute ones, but I am afraid those with braces are not palindromes as their first and last characters are different. – manatwork – 2015-12-15T20:51:49.810

@Oh, right. I'll take those away. – Adám – 2015-12-16T14:40:37.500

0

Mouse-2002, 47 bytes

"Greetings, Planet"33!'$'!33"tenalP ,sgniteerG"

I hate that I have to print !'s charcode because using it in a string just prints \n.

things_to_fix_in_my_mouse_reboot.append("EXCLAMATION POINTS ARE THEMSELVES, NOT NEWLINES.")

cat

Posted 2015-10-03T13:55:39.380

Reputation: 4 989

0

PlatyPar, 40 bytes

"!tenalp ,sgniteerG""Greetings, planet!"

Pushes the two strings to the stack. At the end of the program, the last item of the stack is printed, so the first inverted one is ignored. I see a lot of other answers like this, except mine doesn't have something between the two strings.

Try it online!

Cyoce

Posted 2015-10-03T13:55:39.380

Reputation: 2 690

0

Microscript, 43 bytes

"!tenalP ,sgniteerG"aha"Greetings, Planet!"

Microscript II, 40 bytes

Noncompeting, language postdates the question.

"!tenalP ,sgniteerG""Greetings, Planet!"

SuperJedi224

Posted 2015-10-03T13:55:39.380

Reputation: 11 342

0

Pylongolf, 43 bytes

."Greetings, Planet!"~"!tenalP ,sgniteerG".

~ prints the stack nicely, . resets the stack.
"Greetings, Planet!" pushes the sentence into the stack, ~ prints it.
The rest is a blur.

EDIT: I saved 2 bytes by removing the ~ symbols on both sides.

user47018

Posted 2015-10-03T13:55:39.380

Reputation:

0

Java, 170 164 bytes

interface e{static void main(String[]s){System.out.print("Greetings, Planet!");}}//}};)"!tenalP ,sgniteerG"(trinp.tuo.metsyS{)s][gnirtS(niam diov citats{e ecafretni

user8397947

Posted 2015-10-03T13:55:39.380

Reputation: 1 242

0

Haystack, 43 bytes

"Greetings, Planet!"o|o"!tenalP, sgniteerG"

Here's how this two-dimensional program works:

  • "Greetings, Planet!" pushes a string whose content is Greetings, Planet! to the stack.
  • o prints everything in the stack.
  • | is the needle. The program ends because it found the needle in the haystack!
  • o"!tenalP, sgniteerG" isn't executed as the needle is found before reaching there.

Hello World example(s) from shebang

user8397947

Posted 2015-10-03T13:55:39.380

Reputation: 1 242

0

INXW63CTMNZGS4DU, 42 bytes

"Greetings, Planet!"#"!tenalP, sgniteerG"

A trailing newline is needed at the end

The # character start a comment, and the last value is printed, so this program print "Greetings, Planet!"

TuxCrafting

Posted 2015-10-03T13:55:39.380

Reputation: 4 547

0

PHP, 48 52 bytes

echo"Greetings, Planet!";//;"!tenalP ,sgniteerG"ohce

// comments out the rest of the line, leaving echo"Greetings, Planet!";.
No space is needed between echo and ", meaning this is this the shortest possible response for PHP.

Would have loved a clever excuse to use /* */, but couldn't think of one.

ricdesi

Posted 2015-10-03T13:55:39.380

Reputation: 499

surely you need to add ohce to the end? – user5957401 – 2016-08-09T19:52:24.893

Right you are, no idea how I missed that. – ricdesi – 2016-08-10T14:21:26.547

0

Nim, 49 bytes

echo"Greetings, Planet!"#"!tenalP ,sgniteerG"ohce

Pretty self-explanatory. Uses Nim's short echo syntax and a comment to create the palindrome.

Copper

Posted 2015-10-03T13:55:39.380

Reputation: 3 684

0

Straw, 41 bytes

(Greetings, Planet!)>)!tenalP ,sgniteerG(

Try it online

(Greetings, Planet!) push a string on the stack, > print it. The rest of the program simply fill the stack with junk.

TuxCrafting

Posted 2015-10-03T13:55:39.380

Reputation: 4 547