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 »
Challenges

Comments on Reverse an ASCII string

Post

Reverse an ASCII string

+11
−0

Your goal is to reverse an ascii string. Given a (optionally newline or null terminated) input, output your input in reverse order, optionally followed by a newline. Terminate afterward. Function answers will not be given a newline, and are not expected to output one unless they print the answer to console.

Examples

Assume all inputs are followed by a newline, and are all standard ASCII encoded.

abcdef -> fedcba
Hello, World! -> !dlroW ,olleH
racecar -> racecar

Example program

function solution(x) {
    return x.split("").reverse().join("");
}

Further clarifications

  • No, you don't have to handle nulls correctly.
  • Nor empty inputs.
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (7 comments)
General comments
Jo King‭ wrote almost 4 years ago · edited almost 4 years ago

I would recommend allowing programs to reverse all of STDIN as well. Also, forcing an extra newline to be output rather than allowing it to be optional feels like it makes the challenge more complex than it needs to be. Also, do we have to handle empty inputs?

moony‭ wrote almost 4 years ago

@Jo King Codidact has a "suggest changes" feature right? Can you please use that? As for handling empty inputs: No.

moony‭ wrote almost 4 years ago

There's some artifacts from this challenge being written around an answer instead of the other way around.

Moshi‭ wrote almost 4 years ago

@moony Suggest edits aren't really used for stuff like that; since there are a bunch of limitations (you can't suggest more than one edit, if you change your mind you can't edit your suggested edit, you can't partially incorporate edits etc.) It's much better to use the comments for these sorts of suggestions.

Moshi‭ wrote almost 4 years ago

(Aside: to mention someone you have to put the full username, without spaces)

Lundin‭ wrote almost 4 years ago

Max length of input string?

luser‭ wrote almost 4 years ago

The statement mentions terminating newlines, yet the given examples don't show any, so most of the answers don't care about newlines either.