-2
\$\begingroup\$

This question already has an answer here:

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\$

marked as duplicate by Erik the Outgolfer code-golf Sep 5 '17 at 8:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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\$ – Erik the Outgolfer Sep 5 '17 at 8:18
  • 3
    \$\begingroup\$ SQL WOULD LOVE THIS CHALLENGE. \$\endgroup\$ – Mr. Xcoder Sep 5 '17 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 Sep 7 '17 at 1:54
  • \$\begingroup\$ @tsh That actually lowercases. \$\endgroup\$ – Erik the Outgolfer Sep 7 '17 at 7:53
1
\$\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\$
0
\$\begingroup\$

Pyth, 3 bytes

rQ1

Equivalent to str.upper in python.

\$\endgroup\$
0
\$\begingroup\$

Perl 5, 6 bytes

5 bytes code + 1 for -p.

$_=uc

Try it online!

\$\endgroup\$
0
\$\begingroup\$

JavaScript (ES6), 18 bytes

s=>s.toUpperCase()
\$\endgroup\$
  • 1
    \$\begingroup\$ Without builtins. \$\endgroup\$ – user72349 Sep 5 '17 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 Sep 5 '17 at 9:02
0
\$\begingroup\$

Mathematica, 11 bytes

ToUpperCase
\$\endgroup\$
0
\$\begingroup\$

Jelly, 2 bytes

Œu

Try it online!

\$\endgroup\$
0
\$\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\$

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