Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Comments on The Palindrome Challenge

Post

The Palindrome Challenge

+0
−0

Your task is to write a program, which is palindromic. This means, that you can reverse it's source code and will get the exact same source code.

I don't care, what your program does, as long as it

  • does something visible to the user (like outputting something or creating a file)
  • doesn't do anything harmful.

Your program must consist of at least one character/byte (whatever your language uses). If your chosen language defaults to outputting every character, unless certain "control sequences" are given (such as PHP or HTML for example), your program must have at least one of those sequences if you want to make use of that feature, otherwise you can assume that the correct control sequences have been put around your source code.

Scoring

Take B the number of bytes and U the number of bytes that will be "used" in one execution of your program (excluding, for example, unreachable branches or comments). Now your score is:

$$\frac{U^2}{B}$$

The program with the highest score in any language wins. This scoring system should favor longer programs while penalizing programs with a lot of "unexecutable stuff" in between. Ideally, every character would be part of the executed code.


What do you think of this challenge suggestion? Do you think the scoring criterion is good for this challenge?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (3 comments)
General comments
manassehkatz‭ wrote almost 4 years ago

Wouldn't any language such as PHP (and there are many others) where until an "escape" or "command" mode is entered simply echos all input automatically win? A PHP program "a" would print "a" and score = 1^2/1 = 1, PHP "aba" prints "aba" and score = 3^2/3 = 3...PHP program 1,000,000 of the same character = score 1,000,000, etc.

luap42‭ wrote almost 4 years ago

@manassehkatz You're right. I added an extended rule saying that if you want to use this auto-output, you must include at least one of those command mode sequences. However if you don't want, you can assume that (for example) the <?php and ?> tags are given and don't have to include them into the score calculation. Furthermore, the contest would only be intra-language, so it doesn't matter if the "best" Python program has a lower score than the "best" PHP program.

Hakerh400‭ wrote almost 4 years ago

"The number of bytes used" is undefinable. Checking any non-trivial property of a program is uncomputable. Besides that, the scoring formula U^2/B allows the score to grow without bounds. JS example: console.log(/*/)/**/1+1...+1+1/**/)/*/(gol.elosnoc - replace ... with +1 repeated n times, the score is (2n+20)^2/(2n+47), which is unbounded.