Skip to main content
added 6 characters in body
Source Link
Dom Hastings
  • 24.4k
  • 4
  • 56
  • 93

Perl / JavaScript, 7473 bytes

Perl returns a palindrome and JavaScript 'de-palindromizes' the input string.

s=prompt();console.log(s.slice(0,-s.length/2+.5|02));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,-s.length/2+.5|02));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,-s.length/2+.5|02));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,-s.length/2+.5|02));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,-s.length\/2+.5|02));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,-s.length\/2+.5|02));eg (which, admittedly will mess up your palindrome thatstring if it contains something like "prompt;console.logs.slice0;eg"slice0,-s.length/2;eg"...) with 1;t which is evaled, returning t, the second replaces the end of the string ($) with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!Try it online!

Perl / JavaScript, 74 bytes

Perl returns a palindrome and JavaScript 'de-palindromizes' the input string.

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,s.length\/2+.5|0));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,s.length\/2+.5|0));eg (which, admittedly will mess up your palindrome that contains "prompt;console.logs.slice0;eg"...) with 1;t which is evaled, returning t, the second replaces the end of string $ with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!

Perl / JavaScript, 73 bytes

Perl returns a palindrome and JavaScript 'de-palindromizes' the input string.

s=prompt();console.log(s.slice(0,-s.length/2));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,-s.length/2));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,-s.length/2));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,-s.length/2));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,-s.length\/2));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,-s.length\/2));eg (which, admittedly will mess up your string if it contains something like "prompt;console.logs.slice0,-s.length/2;eg"...) with 1;t which is evaled, returning t, the second replaces the end of the string ($) with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!

typo
Source Link
Dom Hastings
  • 24.4k
  • 4
  • 56
  • 93

Perl / JavaScript, 74 bytes

Perl returns a palindrome and JavaScript 'de-palindomizes'palindromizes' the input string.

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,s.length\/2+.5|0));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,s.length\/2+.5|0));eg (which, admittedly will mess up your palindrome that contains "prompt;console.logs.slice0;eg"...) with 1;t which is evaled, returning t, the second replaces the end of string $ with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!

Perl / JavaScript, 74 bytes

Perl returns a palindrome and JavaScript 'de-palindomizes' the input string.

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,s.length\/2+.5|0));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,s.length\/2+.5|0));eg (which, admittedly will mess up your palindrome that contains "prompt;console.logs.slice0;eg"...) with 1;t which is evaled, returning t, the second replaces the end of string $ with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!

Perl / JavaScript, 74 bytes

Perl returns a palindrome and JavaScript 'de-palindromizes' the input string.

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,s.length\/2+.5|0));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,s.length\/2+.5|0));eg (which, admittedly will mess up your palindrome that contains "prompt;console.logs.slice0;eg"...) with 1;t which is evaled, returning t, the second replaces the end of string $ with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!

Source Link
Dom Hastings
  • 24.4k
  • 4
  • 56
  • 93

Perl / JavaScript, 74 bytes

Perl returns a palindrome and JavaScript 'de-palindomizes' the input string.

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

JavaScript

Assumes the string is a valid palindrome already.

All the work happens in the first section:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:

eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg

Perl

Must be run with -pl, eg:

perl -ple 's=prompt();console.log(s.slice(0,s.length/2+.5|0));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:

s/prompt();console.log(s.slice(0,s.length\/2+.5|0));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,s.length\/2+.5|0));eg (which, admittedly will mess up your palindrome that contains "prompt;console.logs.slice0;eg"...) with 1;t which is evaled, returning t, the second replaces the end of string $ with reverse$_ which is then also evaled and appends the original source string reversed.

Try it online!