-3
\$\begingroup\$

Given a string that consists entirely of printable ASCII, convert all lowercase letters to their uppercase equivalent. Non-lowercase characters are left untouched.

I am not going to outright ban builtin solutions, but if you are going to post a solution that uses the builtin, please also post one that doesn't in your answer.

This is a so shortest code wins, standard rules apply.

Test cases

input => output

Hello, World! => HELLO, WORLD!
TEST => TEST
1gN0r3 50M3 cH4r4C73r5 => 1GN0R3 50M3 CH4R4C73R5

GOOD LUCK GOLFERS!

\$\endgroup\$
4
  • 2
    \$\begingroup\$ I closed this question as a dupe since it's essentially converting a string to a specific case, the only addition being that built-ins are added, which doesn't make this much different in my opinion. If you don't agree with the closure, you can vote to reopen this question. \$\endgroup\$ Commented Sep 5, 2017 at 8:18
  • 3
    \$\begingroup\$ SQL WOULD LOVE THIS CHALLENGE. \$\endgroup\$
    – Mr. Xcoder
    Commented Sep 5, 2017 at 8:39
  • \$\begingroup\$ @EriktheOutgolfer Just got an answer which works for that question but not this one: (JavaScript) a=>a.replace(/[A-Z]/g,a=>parseInt(a,36).toString(36)) \$\endgroup\$
    – tsh
    Commented Sep 7, 2017 at 1:54
  • \$\begingroup\$ @tsh That actually lowercases. \$\endgroup\$ Commented Sep 7, 2017 at 7:53

7 Answers 7

2
\$\begingroup\$

Japt, 05AB1E & 2sable (and probably others), 1 byte

u

Try it: Japt  |  05AB1E  |  2sable

Thanks to Mr. Xcoder for pointing out the polyglots.


Japt Without Built-in, 16 bytes

c_¨#a©Z§#z?Z-H:Z

Try it

\$\endgroup\$
2
1
\$\begingroup\$

Pyth, 3 bytes

rQ1

Equivalent to str.upper in python.

\$\endgroup\$
1
\$\begingroup\$

Perl 5, 6 bytes

5 bytes code + 1 for -p.

$_=uc

Try it online!

\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 18 bytes

s=>s.toUpperCase()
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Without builtins. \$\endgroup\$
    – user72349
    Commented Sep 5, 2017 at 8:20
  • \$\begingroup\$ Thanks, @ThePirateBay; I was about to port my 16 byte Japt solution, which would have been exactly what you posted, when the challenge got dupe-hammered, so I just moved on. \$\endgroup\$
    – Shaggy
    Commented Sep 5, 2017 at 9:02
1
\$\begingroup\$

Mathematica, 11 bytes

ToUpperCase
\$\endgroup\$
1
\$\begingroup\$

Jelly, 2 bytes

Œu

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Python 3, 9 bytes

str.upper

Try it online! or Verify all test cases.


Python 3, 50 bytes

Saved many bytes thanks to @FelipeNardiBatista.

lambda k:''.join(chr(ord(c)-32*(c>'_'))for c in k)

Try it online!

\$\endgroup\$
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.