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

Post History

50%
+0 −0
#6: Post edited by user avatar trichoplax‭ · 2022-10-10T10:27:31Z (over 1 year ago)
Mark as finalized
  • Lowercase, but not just the letters
  • Lowercase, but not just the letters [FINALIZED]
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is `0` for uppercase, and `1` for lower[]()case. Setting this bit to `1` for a non-letter character that previously had it set to `0` results in it changing to a completely unrelated character, which for this challenge we will call the ***lowercase version*** of that character.
  • ## Input
  • - A sequence of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - This may be a string or any ordered data structure of characters
  • - There will never be an underscore `_` (character code 95) as its lowercase version is character code 127, which is outside the printable range and used as a control character
  • ## Output
  • - A sequence of the same number of characters as the input
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this format does not change for different inputs
  • - Each character is either the same as the input, if it was a lowercase version already, or otherwise the lowercase version of the input character
  • ## Examples
  • ### A letter
  • Character "A" is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for "a". So the lowercase version of "A" is "a", as expected.
  • ### A non-letter
  • Character "^" is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the lowercase version of "^" is "~".
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • ## Now posted: [Lowercase, but not just the letters](https://codegolf.codidact.com/posts/287207)
  • ---
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is `0` for uppercase, and `1` for lower[]()case. Setting this bit to `1` for a non-letter character that previously had it set to `0` results in it changing to a completely unrelated character, which for this challenge we will call the ***lowercase version*** of that character.
  • ## Input
  • - A sequence of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - This may be a string or any ordered data structure of characters
  • - There will never be an underscore `_` (character code 95) as its lowercase version is character code 127, which is outside the printable range and used as a control character
  • ## Output
  • - A sequence of the same number of characters as the input
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this format does not change for different inputs
  • - Each character is either the same as the input, if it was a lowercase version already, or otherwise the lowercase version of the input character
  • ## Examples
  • ### A letter
  • Character "A" is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for "a". So the lowercase version of "A" is "a", as expected.
  • ### A non-letter
  • Character "^" is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the lowercase version of "^" is "~".
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#5: Post edited by user avatar trichoplax‭ · 2022-10-10T10:22:07Z (over 1 year ago)
Tidying
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A sequence of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - This may be a string or any ordered data structure of characters
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control character
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A sequence of the same number of characters as the input
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - Each character is either the same as the input, if it was a "lower case version" already, or otherwise the "lower case version" of the input character
  • ## Examples
  • ### A letter
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • ### A non-letter
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is `0` for uppercase, and `1` for lower[]()case. Setting this bit to `1` for a non-letter character that previously had it set to `0` results in it changing to a completely unrelated character, which for this challenge we will call the ***lowercase version*** of that character.
  • ## Input
  • - A sequence of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - This may be a string or any ordered data structure of characters
  • - There will never be an underscore `_` (character code 95) as its lowercase version is character code 127, which is outside the printable range and used as a control character
  • ## Output
  • - A sequence of the same number of characters as the input
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this format does not change for different inputs
  • - Each character is either the same as the input, if it was a lowercase version already, or otherwise the lowercase version of the input character
  • ## Examples
  • ### A letter
  • Character "A" is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for "a". So the lowercase version of "A" is "a", as expected.
  • ### A non-letter
  • Character "^" is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the lowercase version of "^" is "~".
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#4: Post edited by user avatar trichoplax‭ · 2022-10-10T09:29:48Z (over 1 year ago)
Make input and output requirements more flexible
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A string of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control character
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A string of the same number of characters as the input
  • - Each character is either the same as the input, if it was a "lower case version" already, or otherwise the "lower case version" of the input character
  • ## Examples
  • ### A letter
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • ### A non-letter
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A sequence of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - This may be a string or any ordered data structure of characters
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control character
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A sequence of the same number of characters as the input
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - Each character is either the same as the input, if it was a "lower case version" already, or otherwise the "lower case version" of the input character
  • ## Examples
  • ### A letter
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • ### A non-letter
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#3: Post edited by user avatar trichoplax‭ · 2022-10-08T15:47:23Z (over 1 year ago)
Tidying
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A string of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control code
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A string of the same number of characters as the input
  • - Each character is either the same as the input, if it was a "lower case version" already, or otherwise the "lower case version" of the input character
  • ## Examples
  • ### A letter
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • ### A non-letter
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations in answers are optional, but I'm more likely to upvote answers that have one.
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A string of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control character
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A string of the same number of characters as the input
  • - Each character is either the same as the input, if it was a "lower case version" already, or otherwise the "lower case version" of the input character
  • ## Examples
  • ### A letter
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • ### A non-letter
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#2: Post edited by user avatar trichoplax‭ · 2022-10-07T23:31:37Z (over 1 year ago)
Add subheadings for examples
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A string of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control code
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A string of the same number of characters as the input
  • - Each character is either the same as the input, if it was a "lower case version" already, or else the "lower case version" of the input character
  • ## Examples
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations in answers are optional, but I'm more likely to upvote answers that have one.
  • Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.
  • ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".
  • ## Input
  • - A string of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
  • - There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control code
  • - There may be spaces (as this is character code 32)
  • ## Output
  • - A string of the same number of characters as the input
  • - Each character is either the same as the input, if it was a "lower case version" already, or otherwise the "lower case version" of the input character
  • ## Examples
  • ### A letter
  • Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.
  • ### A non-letter
  • Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)
  • ```text
  • " " : " "
  • "!" : "!"
  • "\"" : "\""
  • "#" : "#"
  • "$" : "$"
  • "%" : "%"
  • "&" : "&"
  • "'" : "'"
  • "(" : "("
  • ")" : ")"
  • "*" : "*"
  • "+" : "+"
  • "," : ","
  • "-" : "-"
  • "." : "."
  • "/" : "/"
  • "0" : "0"
  • "1" : "1"
  • "2" : "2"
  • "3" : "3"
  • "4" : "4"
  • "5" : "5"
  • "6" : "6"
  • "7" : "7"
  • "8" : "8"
  • "9" : "9"
  • ":" : ":"
  • ";" : ";"
  • "<" : "<"
  • "=" : "="
  • ">" : ">"
  • "?" : "?"
  • "@" : "`"
  • "A" : "a"
  • "B" : "b"
  • "C" : "c"
  • "D" : "d"
  • "E" : "e"
  • "F" : "f"
  • "G" : "g"
  • "H" : "h"
  • "I" : "i"
  • "J" : "j"
  • "K" : "k"
  • "L" : "l"
  • "M" : "m"
  • "N" : "n"
  • "O" : "o"
  • "P" : "p"
  • "Q" : "q"
  • "R" : "r"
  • "S" : "s"
  • "T" : "t"
  • "U" : "u"
  • "V" : "v"
  • "W" : "w"
  • "X" : "x"
  • "Y" : "y"
  • "Z" : "z"
  • "[" : "{"
  • "\\" : "|"
  • "]" : "}"
  • "^" : "~"
  • "`" : "`"
  • "a" : "a"
  • "b" : "b"
  • "c" : "c"
  • "d" : "d"
  • "e" : "e"
  • "f" : "f"
  • "g" : "g"
  • "h" : "h"
  • "i" : "i"
  • "j" : "j"
  • "k" : "k"
  • "l" : "l"
  • "m" : "m"
  • "n" : "n"
  • "o" : "o"
  • "p" : "p"
  • "q" : "q"
  • "r" : "r"
  • "s" : "s"
  • "t" : "t"
  • "u" : "u"
  • "v" : "v"
  • "w" : "w"
  • "x" : "x"
  • "y" : "y"
  • "z" : "z"
  • "{" : "{"
  • "|" : "|"
  • "}" : "}"
  • "~" : "~"
  • "([({Enclosed})])" : "({({enclosed})})"
  • "A@B.c" : "a`b.c"
  • ```
  • ## Rules
  • - There is no requirement to use bitwise operations to achieve the correct output
  • - Provided your output is correct for each input, your code is valid
  • > Explanations in answers are optional, but I'm more likely to upvote answers that have one.
#1: Initial revision by user avatar trichoplax‭ · 2022-10-07T23:25:46Z (over 1 year ago)
Lowercase, but not just the letters
Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.

ASCII characters that are letters have a bit in their binary representation that is 0 for upper case, and 1 for lower case. Setting this bit to 1 means that regardless of the previous case of the letter, it will now be lower case. Doing the same for non-letter characters results in some characters changing to a completely unrelated character, which for this challenge we will call the "lower case version".

## Input
- A string of characters, each of which is a printable ASCII character (character codes 32 to 126 inclusive)
- There will never be an underscore `_` (character code 95) as its "lower case version" is character code 127, which is outside the printable range and used as a control code
- There may be spaces (as this is character code 32)

## Output
- A string of the same number of characters as the input
- Each character is either the same as the input, if it was a "lower case version" already, or else the "lower case version" of the input character

## Examples
Character `A` is character code 65, or `1000001` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1100001`, or 97, which is the character code for `a`. So the "lower case version" of `A` is `a`, as expected.

Character `^` is character code 94, or `1011110` in binary. The bit in position 5 from the right, representing $2^5$, is `0`. Setting this bit to `1` gives `1111110`, or 126, which is the character code for "~". So the "lower case version" of `^` is `~`.


## Test cases
Test cases are in the format `"input" : "output"`

Note that `"` and `\` have both been escaped with a preceding `\`, because they are enclosed in double quotes, but each still represents a single character)

```text
" " : " "
"!" : "!"
"\"" : "\""
"#" : "#"
"$" : "$"
"%" : "%"
"&" : "&"
"'" : "'"
"(" : "("
")" : ")"
"*" : "*"
"+" : "+"
"," : ","
"-" : "-"
"." : "."
"/" : "/"
"0" : "0"
"1" : "1"
"2" : "2"
"3" : "3"
"4" : "4"
"5" : "5"
"6" : "6"
"7" : "7"
"8" : "8"
"9" : "9"
":" : ":"
";" : ";"
"<" : "<"
"=" : "="
">" : ">"
"?" : "?"
"@" : "`"
"A" : "a"
"B" : "b"
"C" : "c"
"D" : "d"
"E" : "e"
"F" : "f"
"G" : "g"
"H" : "h"
"I" : "i"
"J" : "j"
"K" : "k"
"L" : "l"
"M" : "m"
"N" : "n"
"O" : "o"
"P" : "p"
"Q" : "q"
"R" : "r"
"S" : "s"
"T" : "t"
"U" : "u"
"V" : "v"
"W" : "w"
"X" : "x"
"Y" : "y"
"Z" : "z"
"[" : "{"
"\\" : "|"
"]" : "}"
"^" : "~"
"`" : "`"
"a" : "a"
"b" : "b"
"c" : "c"
"d" : "d"
"e" : "e"
"f" : "f"
"g" : "g"
"h" : "h"
"i" : "i"
"j" : "j"
"k" : "k"
"l" : "l"
"m" : "m"
"n" : "n"
"o" : "o"
"p" : "p"
"q" : "q"
"r" : "r"
"s" : "s"
"t" : "t"
"u" : "u"
"v" : "v"
"w" : "w"
"x" : "x"
"y" : "y"
"z" : "z"
"{" : "{"
"|" : "|"
"}" : "}"
"~" : "~"
"([({Enclosed})])" : "({({enclosed})})"
"A@B.c" : "a`b.c"
```

## Rules
- There is no requirement to use bitwise operations to achieve the correct output
- Provided your output is correct for each input, your code is valid

> Explanations in answers are optional, but I'm more likely to upvote answers that have one.