# Challenge

You will be given a string as an argument. You need to convert that string to upper case. But you can't use any built in method or function nor any external programs.

# Rule

No use of built in methods or functions or external programs. Only arithmetic, bitwise, logical operators, regex, replace, split, join, ASCII codes are allowed.

# Input

The string as an argument. The string can contain spaces and special characters.

# Output

The string in upper case.

This is so shortest code wins.

• Does "one two" become "One two", "One Two", or "ONE TWO"? – PkmnQ Mar 8 at 8:21
• "ONE TWO" @Want – Wasif Hasan Mar 8 at 8:21
• Can contain spaces and special characters : does that include code points $\ge127$? – Arnauld Mar 8 at 8:46
• We can assume that any keyboard is acceptable? – ouflak Mar 8 at 9:07
• I still think this question is unclear. What is allowed and not allowed is only vaguely explained. But additionally since special characters must be supported it is unclear what characters need to be made "upper case" and what that means. E.g. do we need to make á into Á? – Ad Hoc Garf Hunter Mar 16 at 20:31

# Japt, 5 bytes

;dCíB


Try it here

• @Downvoters, please have the decency to leave I comment! – Shaggy Mar 16 at 21:12

# Turing Machine Code, 279 bytes

0 q Q r 0
0 w W r 0
0 e E r 0
0 r R r 0
0 t T r 0
0 y Y r 0
0 u U r 0
0 i I r 0
0 o O r 0
0 p P r 0
0 a A r 0
0 s S r 0
0 d D r 0
0 f F r 0
0 g G r 0
0 h H r 0
0 j J r 0
0 k K r 0
0 l L r 0
0 z Z r 0
0 x X r 0
0 c C r 0
0 v V r 0
0 b B r 0
0 n N r 0
0 m M r 0
0 _ _ r 0
0 * * r 0


Try it online!

# 05AB1E, 8 5 bytes

(Once again, a'_' uses something that I didn't know even existed in 05AB1E.)

AžpR‡


## Explanation

       # Implicit input
A      # Push lowercase alphabet
žp    # Push uppercase alphabet reversed
R   # And reverse it again
‡  # Transliterate
J # Join list


Try it online!

# Original solution without ‡, 19 18 bytes

εDAskD®ÊižpRèës}}J


Try it online!

## Explanation

                   # Implicit input
ε               }  # Loop on each character
εD              }  # Duplicate
ε A             }  # Push lowercase alphabet
ε  s            }  # Swap
ε   k           }  # Find index of character in alphabet
ε    D          }  # Duplicate for comparison
ε     ®         }  # Push -1 (see link below)
ε      Ê        }  # Check if equal
ε       i    ë }}  # If-else statement
ε       ižp  ë }}  # Push uppercase alphabet in reverse
ε       i  R ë }}  # Reverse the string (so now it's just the uppercase alphabet)
ε       i   èë }}  # Index the uppercase alphabet
ε       i    ës}}  # Swap to get character
J # Join all the items


If you're wondering why ® returns -1, go here

• 5B. (Ab)uses the transliteration. – petStorm Mar 8 at 10:13
• FYI I can do it without transliteration in 13 bytes: εDAus«sAskè}J. – Neil Mar 8 at 11:00
• @Neil this uses the built-in u, making it invalid. 14 bytes using žpR instead of Au. – Grimmy Mar 9 at 13:16

# Batch, 245 116 Bytes

@Set v=%~1
@for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)do @call set v=%%v:%%A=%%A%%
@ECHO(%v%


Somewhat ugly and brute forced, using a for loop to enact substring modification on each instance of a character. 129 bytes dropped thanks to Neil

• Hey thanks for submission. It works, but it's way too long (245 bytes!) – Wasif Hasan Mar 8 at 8:41
• indeed, but that's batch. no means within the language of batch to shorten it further. (I have 0 expectations of providing the shortest answer) – T3RR0R Mar 8 at 8:44
• @set/pv= is a slightly golfier way to take input. – Neil Mar 8 at 10:40
• Substring replacement is case-insensitive in Batch, so you can simply use @for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)do @call set v=%%v:%%A=%%A%% (using call also removes the need to enable delayed expansion). – Neil Mar 8 at 10:42
• One of those little details I clean forgot. Answer updated. – T3RR0R Mar 8 at 11:12

# Erlang (escript), 56 bytes

Numeric lists are strings in Erlang. (9 bytes away from C, let's see if I can get this shorter.)

f([H|T])->[H-if H>97,H<122->32;1<2->0end]++f(T);f(N)->N.


Try it online!

## Explanation

f([H | T]) -> % Try to split the input into head & tail
[H -          % Subtract the current item by:
if
H > 97, H < 122 -> 32;
% If the item's ord code is in the lowercase letter range:Return 32
1 < 2 -> 0  % Otherwise, return 0. 1<2 is 1 byte shorter than true.
end
] ++ f(T);    % Concatenate with the uppercased tail

f(N) -> N.    % If the tail is the null list (i.e. it can't be splitted):
% Return this operand.
$$$$


# Bash + core utilities, 10 bytes

tr a-z A-Z


Try it online!

# 4, 54 bytes

Thanks to @PkmnQ for pointing out the bug!

3.6993269897697017008003010098801100009960100950070094


Try it online!

# 4, 28 bytes (old answer, only supports lower case and nothing else XD)

3.69932700800100009950070094


Try it online!

• Cool, but if you input a capital letter it becomes gibberish. – PkmnQ Mar 8 at 10:36
• Welp, fix is underway – Felixnyancat Mar 8 at 10:43

# C (gcc), 47 45 bytes

Saved 2 bytes thanks to ceilingcat!!!

f(char*s){for(;*s;++s)*s^=*s>96&*s<123?32:0;}


Try it online!

• @ceilingcat That's the way to golf if statement followed by assignment - thanks! :-) – Noodle9 Mar 9 at 21:29

# Keg, 14 bytes

(&az⑻•[& -|&],


Try it online!

Finally! A challenge Keg was designed for! This utilises the fact that a) subtracting 32 from the ordinal value of any lower-case letter gives its upper-case counterpart and b) characters are treated as numbers when arithmetic is applied.

The unicode part is to ensure the letter is in the lower case range, without using built-ins.

• Hey @Downvoters, at least be courteous enough to leave a comment explaining what y'all think is wrong here. – Lyxal Mar 16 at 21:59

# APL+WIN, 28 bytes

Prompts for string:

⎕av[i-32×(i←⎕av⍳⎕)∊(97+⍳26)]


Converts string to relevant indices in APL's atomic vector, identifies indices of lower case letters, decrements only those indices by 32 and converts resulting string back to characters.

• @a'_' Not sure. The rules state ascii codes are supported and that is effectively what is in the APL atomic vector. – Graham Mar 8 at 9:50

# Charcoal, 9 bytes

⭆Ｓ§⁺αι⌕βι


Try it online! Link is to verbose version of code. Only 7 bytes longer than the built-in! Explanation:

 Ｓ          Input string
⭆           Map over characters and join
⌕     Find index in
β    Lowercase alphabet of
ι   Current character
§         Cyclically index into
⁺        Concatenation of
α       Uppercase alphabet
ι      Current character
Implicitly print


If the input character is not found in the lowercase alphabet, the returned index is -1, which represents the last character when passed to the cyclic index function.

# Retina, 5 bytes

TlL


Try it online!

Transliterate lower case letters into upper case Letters.

## 16/32/64-bit x86 assembly language, 17 bytes

AC    l1: lodsb
3C 61     cmp   al, 'a'
72 06     jb    l2
3C 7A     cmp   al, 'z'
77 02     ja    l2
24 DF     and   al, 0dfh ;convert to uppercase
AA    l2: stosb
84 C0     test  al, al
75 F0     jne   l1
60        ret`

Call with (r/e)si pointing to source string, (r/e)di to destination buffer to hold converted text.