Reverse a String in Every Language
Published on 01 November 2018 (Updated: 02 May 2020)
While Hello World is simple, it often does not show off many interesting features of a language. Fortunately, this repository shares more samples than Hello World. One of these more complex programs is known as Reverse a String.
In this repository, the algorithm must reverse ASCII strings. Do NOT worry about reversing a string in the general case. For instance, if a string contains surrogate pairs, it’s okay if the solution corrupts the string during reversal.
Requirements
Despite the explicit name, there are some rules in place for consistency. When writing a Reverse a String program, the following rules should apply:
- The implementation must be executable
- The string to be reversed must come from the command line
- The program must verify the strings existence on the command line
- The user must not import libraries to obfuscate the string manipulation
In other words, the program should get a string from the command line and reverse it using language utilities only. Acceptable language utilities include language features and built-in libraries.
External dependencies are unacceptable. Remember, the goal is to show off language features and utilities.
Testing
If the solution passes these test cases, then it’s a good fit for the repo. Feel free to test other strings for fun. For instance, you may find that your language can handle unicode characters, but it fails for emojis.
Description | Input | Output |
---|---|---|
No Input | ||
Empty String | ”” | |
Ascii String | “Hello, World” | “dlroW ,olleH” |
Articles
-
Reverse a String in C on 01 October 2020 by Abhishek Raut
-
Reverse a String in Dart on 16 October 2019 by P. Ryon (slashdoom)
-
Reverse a String in Java on 22 December 2018 by Jeremy Grifski
-
Reverse a String in JavaScript on 01 October 2019 by Pascal Spiesz
-
Reverse a String in Lua on 03 October 2019 by Matt Wiley
-
Reverse a String in Python on 24 December 2018 by Jeremy Grifski
-
Reverse a String in Ruby on 24 December 2018 by Noah Nichols
-
Reverse a String in Scheme on 24 December 2018 by Alexandra Wörner
-
Reverse a String in Swift on 25 December 2018 by Marty Hernandez Avedon
-
Reverse a String in Visual Basic on 07 October 2019 by