| Bytes | Lang | Time | Link |
|---|---|---|---|
| 103 | Rust | 240919T172709Z | bzr |
| 023 | Uiua | 240921T012016Z | Adelie |
| 015 | Japt P | 201023T200305Z | Shaggy |
| 037 | bash + coreutils | 231121T192450Z | Someone |
| 100 | JavaScript | 201024T192110Z | bzr |
| 101 | Lexurgy | 220121T063731Z | bigyihsu |
| 010 | Vyxal | 210221T013116Z | lyxal |
| 029 | Zsh | 210221T133913Z | pxeger |
| nan | PowerShell | 210221T051750Z | Wasif |
| 105 | Befunge93 | 201106T094431Z | DarkAndr |
| 029 | Raku | 201101T174328Z | Sean |
| 056 | R | 201024T063153Z | Robin Ry |
| 033 | x86 machine code MSDOS .COM format | 201024T232714Z | ErikF |
| 040 | Scala | 201025T060217Z | Tomer Sh |
| 028 | GolfScript | 201023T213031Z | 2014MELO |
| 024 | CJam | 201027T101801Z | JosiahRy |
| 041 | Pyth | 201027T063218Z | PkmnQ |
| 018 | Charcoal | 201023T200909Z | Neil |
| 054 | JavaScript ES6 | 201024T113857Z | Arnauld |
| 039 | APL+WIN | 201024T112151Z | Graham |
| 027 | Perl 5 | 201024T112032Z | Kjetil S |
| 037 | Ruby nl | 201024T103045Z | Kirill L |
| 013 | 05AB1E | 201023T203328Z | ovs |
| 043 | Haskell | 201024T085857Z | xnor |
| 060 | C gcc | 201023T224036Z | Noodle9 |
| 017 | Husk | 201024T043555Z | Razetime |
| 049 | C gcc | 201024T020909Z | ErikF |
| 048 | Haskell | 201024T014905Z | lynn |
| 051 | Python 3 | 201023T201348Z | hyper-ne |
| 026 | Retina 0.8.2 | 201023T195933Z | Neil |
| 015 | Jelly | 201023T200212Z | caird co |
Rust, 111 103 bytes
-8 bytes thanks to ceilingcat
let f=|s:&str|{for c in s.chars(){let e=c.to_digit(10).unwrap()as usize;dbg!(&"nubtqphsoe"[e..e+1]);}};
Uiua, 23 bytes
⊂⊙(↘1)⌵⊢.⊏:"nubtqphsoe"
Function that takes in an array of digits and maps each digit to a letter. Try it online!
Explanation
⊂⊙(↘1)⌵⊢.⊏:"nubtqphsoe" # main function
"nubtqphsoe" # string literal
: # flip top 2 stack values
⊏ # pick multiple characters from the string using the input array's elements as indexes,
# which creates another string
. # duplicate said string
⊢ # take the first character of the string
⌵ # convert character to uppercase
⊙( ) # temporarily pop this character from the stack, then:
↘1 # drop the first character from the string
# after this, the character is pushed back to the stack
⊂ # join the character and string together
Japt -P, 17 16 15 bytes
ì`eo¢pqt¿n`Ô vu
ì`...`Ô vu :Implicit input of integer
ì :Convert to digit array in custom base
`...` : Compressed string "eoshpqtbun"
Ô : Reverse
v :Modify first element
u : Uppercase
:Implicitly join and output
bash + coreutils, 40 37 bytes
c=`tr 0-9 nubtqphsoe<<<$1`
echo ${c^}
JavaScript, 264 157 150 100 bytes
-107 bytes by replacing if statements with a JavaScript object to match each number with a corresponding string.
-7 bytes by using ES6 for loop through a string, and shorter arrow functions.
-50 bytes by replacing JavaScript Object with ES6 string indexing.
a='';o='nubtqphsoe';x=c=>a+=o[c];for(let e of prompt())x(e);alert(a[0].toUpperCase()+a.substring(1))
Lexurgy, 101 bytes
Map a digit to its respective letter.
Class D {\0,\1,\2,\3,\4,\5,\6,\7,\8,\9}
a:
@D=>{N,U,B,T,Q,P,H,S,O,E}/$ _
@D=>{n,u,b,t,q,p,h,s,o,e}
Vyxal, 11 10 bytes
«/
∨+Ċ≤«βǐ
I finally turned my suggested 13 byte 05AB1E answer into a Vyxal answer.
Explained
«...«βǐ
«...« # the string "nubtqphsoe"
β # convert the input to bijective-base 10 using the above string as the alphabet
ǐ # titlecase that result
PowerShell, 142 100 94 bytes
$k=[string]$args;0..9|%{$k=$k.replace([string]$_,'nubtqphsoe'[$_])};get-culture|% t*o|% *se $k
Befunge-93, 105 bytes
Terrible implementation, it works at least, input is each digit of the number then any other character to terminate. Feel free to suggest any optimisations.
~::68*`vnubtqphsoe
v+4*96_@
`
@_68*8--0 v
v <
v:~<,-*84g<
>:68*` v
v+4*96_@
`
@_68*8--0 g,^
R, 80 72 56 bytes
-8 bytes thanks to Kirill L.
-16 bytes thanks to Giuseppe.
sub("(.)","\\U\\1",chartr("0-9","nubtqphsoe",scan()),,T)
First we translate the digits to the relevant letters thanks to chartr, then sub switches the first letter to upper case. This last part is possible thanks to the option perl = T, a nice trick found by Giuseppe.
Also, note that all the functions are vectorized the way we need them to be, so we can handle several inputs at a time, which is rather unusual in R golf with scan().
x86 machine code (MS-DOS .COM format), 35 33 bytes
The program will terminate at the end of input from the command line.
For fun, I decided to use XLAT to index each digit's representation as the translation array easily fits into an 8-bit index and everything is 1:1.
Byte representation:
0000 B4 20 BB 19 01 BE 82 00 AC 2C 0D 74 09 D7 32 C4
0010 CD 29 32 E4 EB F0 C3 6E 75 62 74 71 70 68 73 6F
0020 65
Assembly code (TASM):
IDEAL
MODEL TINY
CODESEG
ORG 100H
SYMS_M EQU OFFSET SYMS-23H
MAIN:
MOV AH,20H
MOV BX,SYMS_M
MOV SI,82H
VAL:
LODSB
SUB AL,0DH
JZ QUIT
XLATB
XOR AL,AH
INT 29H
XOR AH,AH
JMP VAL
QUIT:
RET
SYMS DB "nubtqphsoe"
END MAIN
ENDS
GolfScript, 31 29 28 bytes
~{"nubtqphsoe"1/=}%()[32-]|\
Input as a digit array.
~ # Parse the input to an array [6 8 5 9]
{ }% # For each digit
"nubtqphsoe"1/ # Split each letter of this string 6 ["n" "u" ... "e"]
= # Get the corresponding letter "h"
( # Get the first letter ["o" "p" "e"] "h"
) # Get the ascii value ["o" "p" "e"] "" 104
32- # Subtract 32 ["o" "p" "e"] "" 72
[ ] # Put it in an array ["o" "p" "e"] "" [72]
| # Convert to ascii ["o" "p" "e"] "H"
\ # Swap the two elements in the stack "H" ["o" "p" "e"]
# Only the strings are outputted "Hope"
Pyth, 41 bytes
V.T,.T]."buÞ;UØ".T]."09IÒ"=:zeNhN;rz3
Explanation
The main part of the program is .T,.T]."buÞ“;UØ".T]."09I–Ò", which returns the list [['u', '1'], ['b', '2'], ['t', '3'], ..., ['n', '0']]. ."buÞ“;UØ" is the packed string ubtqphsoen, and ."09I–Ò" is the packed string 1234567890. .T] splits them into characters, and .T, zips them together.
Pyth, 24 bytes
Vz=+k@."bu\nL"vN;rk3
This one is a port of HyperNeutrino's Python 3 answer.
Charcoal, 20 18 bytes
⭆⍘Nnubtqphsoe⎇κι↥ι
Try it online! Link is to verbose version of code. Edit: Saved 2 bytes thanks to @Lyxal's comment on @ovs's answer. Explanation:
N Input number
⍘ Custom base conversion using
nubtqphsoe Literal string
⭆ Map over characters
κ Current index
⎇ If not first character then
ι Current character
↥ι Else uppercased character
Implicitly print
JavaScript (ES6), 54 bytes
Expects an array of digits.
a=>a.map((c,i)=>"nNuUbBtTqQpPhHsSoOeE"[c*2+!i]).join``
APL+WIN, 39 bytes
Prompts for a character vector of digits with index origin = 0
⎕av[(↑n),32+1↓n←⎕av⍳'NUBTQPHSOE'[⍎¨⍕⎕]]
Explanation:
[⍎¨⍕⎕]] Convert input to individual digits
⎕av⍳'NUBTQPHSOE' Find index positions of all upper case characters in atomic vector
and use result above to select those according to input
(↑n),32+1↓n Concatenate first index to remaining indices + 32 to apply appropriate case
⎕av[...] Use the above indices to select required characters from atomic vector
05AB1E, 13 bytes
Input is a list of digits.
.•*Š"—Êo•sèJ™
Try it online! or Try all cases!
Commented:
.•*Š"—Êo• # compressed alphabet string "nubtqphsoe"
s # swap to implicit input
è # index each digit into the string
J # join into a single string
™ # apply title case
See the step-by-step output here.
Lyxal has suggested another 13-byter with a nicer input format:
.•*Š"—Êo•ÅвJ™
This uses Åв, which converts the input integer into the custom base defined by the string.
Haskell, 43 bytes
f(h:t)="NUBTQPHSOE"!!h:map("nubtqphsoe"!!)t
Input is a list of digits. Yes, the code really just writes out the string once in uppercase and a second time in lowercase. This kludge seems shorter than other things I tried. Haskell without imports doesn't have built-ins to capitalize and is really clumsy in working with characters.
43 bytes
zipWith(!!)$"NUBTQPHSOE":repeat"nubtqphsoe"
Taking Lynn's solution and making it more boring. We can also write:
43 bytes
zipWith(!!)$"NUBTQPHSOE":l
l="nubtqphsoe":l
47 bytes
(%0)
(h:t)%i=["NUBTQPHSOE"!!h..]!!i:t%32
_%_=""
Based off Lynn's solution. Handles the capitalization by passing in an offset i of 0 initially, then updating it to 32 in each recursive function call.
It doesn't seem like Haskell has a nice function to title-case a string even with imports, which are probably too lengthy anyway to be competitive. The below with Data.Text doesn't work because it operates on Text not [Char]. Data.Char only has toUpper to capitalize a single character.
44 bytes (non-working)
import Data.Text
toTitle.map("NUBTQPHSOE"!!)
C (gcc), 63 60 bytes
Saved 3 bytes thanks to AZTECCO!!!
f(a,l)int*a;{l--&&f(a,l)+putchar("nubtqphsoe"[a[l]]-!l*32);}
Inputs a pointer to an array of digits and its length (since there's no way to know how long an array passed into a function as a pointer is in C) and prints the corresponding systematic chemical symbol.
Husk, 20 17 bytes
§:oa←tm!¨Ḃ+q²"ṗen
input as a list of digits.
There's probably a better way to do the titlecasing part.
-3 bytes from Dominic van Essen.
Explanation (old)
§:oa←tmo!¨nḂ+q²"ṗe¨→
→ increment input to accomodate 0-indexing
mo map each digit to
!¨nḂ+q²"ṗe¨ it's index value in the compressed string
§: join the
oa← first letter uppercased
t with it's tail
C (gcc), 51 49 bytes
Apparently I can get rid of the customary "assign to first parameter" because I only care about a false/non-false answer from this function. Interesting to know!
f(n){n&&putchar("nubtqphsoe"[n%10]^32*!f(n/10));}
Python 3, 51 bytes
lambda a:"".join("nubtqphsoe"[x]for x in a).title()
Proton, 42 bytes
a=>"".join("nubtqphsoe"[x]for x:a).title()
Retina 0.8.2, 26 bytes
T`d`nubtq\p\hs\oe
T`l`L`^.
Try it online! Link includes test cases. Explanation:
T`d`nubtq\p\hs\oe
Translate each digit to the appropriate letter. The letters h, o and p have special meaning, so they need to be quoted.
T`l`L`^.
Translate the first letter to upper case.
Jelly, 15 bytes
ị“ubtqphsoen”Œt
Inputs as a list of digits, which the Footer does for you.
As it appears the string can't be compressed, this is likely to be the shortest approach in Jelly
How it works
ị“ubtqphsoen”Œt - Main link. Takes a list l on the left
“ubtqphsoen” - Yield the string “ubtqphsoen”
ị - For each digit in l, index into the string (1-indexing)
Œt - Title case (capitalise the first character)