1
\$\begingroup\$

Challenge

Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird).

Then, your program should output a superscript version.

Example

Input: hello world

Output: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈ

Test Cases

hello - ʰᵉᶫᶫᵒ
code - ᶜᵒᵈᵉ
golf - ᵍᵒᶫᶠ
asdf - ᵃˢᵈᶠ
qwerty - ᑫʷᵉʳᵗʸ
abcdefghijklmnopqrstuvwxyz - ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ

Help

If you need help understanding check out this website, it's a translator: http://txtn.us/tiny-text

Code Golf

This is a code golf, so the shortest code wins!

Good luck!

Edits

Edit #1: There will be no caps, since I just realized they look weird.

\$\endgroup\$
11
  • 2
    \$\begingroup\$ Will they be all lowercase? \$\endgroup\$
    – ASCII-only
    May 29, 2017 at 10:47
  • \$\begingroup\$ Related \$\endgroup\$
    – Beta Decay
    May 29, 2017 at 10:48
  • \$\begingroup\$ @BetaDecay They're related but this is superscript \$\endgroup\$ May 29, 2017 at 10:49
  • \$\begingroup\$ @BetaDecay Oops, sorry. \$\endgroup\$ May 29, 2017 at 10:51
  • \$\begingroup\$ @ASCII-only I changed my mind, see edit, all lowercase. \$\endgroup\$ May 29, 2017 at 10:53

5 Answers 5

5
\$\begingroup\$

JavaScript (ES6), 10 bytes

s=>s.sup()

It should be noted that the sup() method has been deprecated so this solution may not work in all browsers nor is it guaranteed to continue working in future releases of browsers that do currently support it. Tested and confirmed to work in Chrome v58.


Try it

f=
s=>s.sup()
o.innerHTML=(i.value="Hello!")+": "+f(i.value)
oninput=_=>o.innerHTML=i.value+": "+f(i.value)
*{font-family:arial,sans-serif}
<input id=i><p id=o>

\$\endgroup\$
6
  • \$\begingroup\$ Can you add a code snippet try me thing? \$\endgroup\$ May 29, 2017 at 10:48
  • \$\begingroup\$ @NoahCristino, Snippet added. \$\endgroup\$
    – Shaggy
    May 29, 2017 at 10:52
  • \$\begingroup\$ @Shaggy That's weird, when I converted something like: CAPSLOCK@^&@^& with the website, I get: ᶜᴬᴾˢᴸᴼᶜᴷ@^﹠@^﹠, but with your it works right. \$\endgroup\$ May 29, 2017 at 10:55
  • \$\begingroup\$ @Shaggy Yeah, that's probably it \$\endgroup\$
    – Beta Decay
    May 29, 2017 at 10:55
  • \$\begingroup\$ Deprecated, but still works with all major browsers so gets my vote: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… \$\endgroup\$ May 29, 2017 at 11:02
3
\$\begingroup\$

PHP+HTML, 17 Bytes

<sup><?=$_GET[0];
\$\endgroup\$
9
  • \$\begingroup\$ Doesn't this still display normal characters, in a superscript size and position? \$\endgroup\$
    – L3viathan
    May 29, 2017 at 10:56
  • 1
    \$\begingroup\$ <sup><?=$_GET[0]; \$\endgroup\$
    – Christoph
    May 29, 2017 at 11:03
  • \$\begingroup\$ @L3viathan Yes and the input is limited to letters \$\endgroup\$ May 29, 2017 at 11:13
  • \$\begingroup\$ How is it limited to letters? \$\endgroup\$
    – Shaggy
    May 29, 2017 at 11:14
  • 1
    \$\begingroup\$ @L3viathan If your understanding is right there are two other invalid answers from Shaggy and Kevin Cruijssen \$\endgroup\$ May 29, 2017 at 11:32
2
\$\begingroup\$

Mathematica, 13 bytes

#~Style~Tiny&
\$\endgroup\$
2
\$\begingroup\$

Java 8 (AWT / Swing), 79 bytes

s->new java.awt.Frame(){{add(new javax.swing.JLabel("<html><sup>"+s));show();}}

Unfortunately there is no reliable online compiler available for Java GUI, so no TIO-link.

Java 8 (Console), 123 117 bytes

s->{for(int x:s.toCharArray())System.out.print("ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ".charAt(x-97));}

Try it here.

\$\endgroup\$
2
  • \$\begingroup\$ Do you need the <html> tag? \$\endgroup\$
    – Shaggy
    May 29, 2017 at 11:53
  • \$\begingroup\$ @Shaggy Unfortunately yes, I've already tried without it when I posted the answer. Without it just outputs <sup>sometext literally. It will probably enable html if it sees the <html> text in the JLabel. \$\endgroup\$ May 29, 2017 at 12:01
1
\$\begingroup\$

Pyth, 75 bytes (30 chars)

XwG"ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ

Try it!

\$\endgroup\$

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