Converting a string to lower-case (without built-in to-lower functions!)
Python 2.7 - 30 (with terrible and unapologetic rule abuse)
raw_input().upper().swapcase()
As an anonymous edit pointed out, you can do it in 27 26 in Python 3:
input().upper().swapcase()
I'm flagrantly abusing the rules here, but...
Important: you are NOT allowed to use a built-in function that converts the string (or just one character) to lowercase (such as
ToLower()
in .NET,strtolower()
in PHP , ...)! You're allowed to use all other built-in functions, however.
This takes the strings and coverts it to upper case. Then in a very unrelated method call, it reverses the case of the string - so that any lower case letters become upper case letters... and swaps any upper case letters to lower case letters.
Perl - 11 10 characters.
y/A-Z/a-z/
y///
is same as tr///
!
In action:
% perl -pe 'y/A-Z/a-z/' <<< 'Hello @ WORLD !'
hello @ world !
Shell - 10
Translation of @Gowtham's Perl solution using /bin/tr
.
tr A-Z a-z
Sample run:
% tr A-Z a-z <<<'Hello WORLD! @'
hello world! @