1
\$\begingroup\$

This question already has an answer here:

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

marked as duplicate by Peter Taylor code-golf May 29 '17 at 11:32

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\$ Will they be all lowercase? \$\endgroup\$ – ASCII-only May 29 '17 at 10:47
  • \$\begingroup\$ Related \$\endgroup\$ – Beta Decay May 29 '17 at 10:48
  • \$\begingroup\$ @BetaDecay They're related but this is superscript \$\endgroup\$ – Noah Cristino May 29 '17 at 10:49
  • \$\begingroup\$ @BetaDecay Oops, sorry. \$\endgroup\$ – Noah Cristino May 29 '17 at 10:51
  • \$\begingroup\$ @ASCII-only I changed my mind, see edit, all lowercase. \$\endgroup\$ – Noah Cristino May 29 '17 at 10:53
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\$
  • \$\begingroup\$ Can you add a code snippet try me thing? \$\endgroup\$ – Noah Cristino May 29 '17 at 10:48
  • \$\begingroup\$ @NoahCristino, Snippet added. \$\endgroup\$ – Shaggy May 29 '17 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\$ – Noah Cristino May 29 '17 at 10:55
  • \$\begingroup\$ @Shaggy Yeah, that's probably it \$\endgroup\$ – Beta Decay May 29 '17 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\$ – Rick Hitchcock May 29 '17 at 11:02
3
\$\begingroup\$

PHP+HTML, 17 Bytes

<sup><?=$_GET[0];
\$\endgroup\$
  • \$\begingroup\$ Doesn't this still display normal characters, in a superscript size and position? \$\endgroup\$ – L3viathan May 29 '17 at 10:56
  • 1
    \$\begingroup\$ <sup><?=$_GET[0]; \$\endgroup\$ – Christoph May 29 '17 at 11:03
  • \$\begingroup\$ @L3viathan Yes and the input is limited to letters \$\endgroup\$ – Jörg Hülsermann May 29 '17 at 11:13
  • \$\begingroup\$ How is it limited to letters? \$\endgroup\$ – Shaggy May 29 '17 at 11:14
  • 1
    \$\begingroup\$ @L3viathan If your understanding is right there are two other invalid answers from Shaggy and Kevin Cruijssen \$\endgroup\$ – Jörg Hülsermann May 29 '17 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\$
  • \$\begingroup\$ Do you need the <html> tag? \$\endgroup\$ – Shaggy May 29 '17 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\$ – Kevin Cruijssen May 29 '17 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.