| Bytes | Lang | Time | Link |
|---|---|---|---|
| 017 | Juby | 250503T022947Z | Jordan |
| 018 | Funky | 171116T233552Z | ATaco |
| 024 | Python 2 | 170706T214330Z | totallyh |
| 017 | JavaScript ES6 | 170707T142023Z | Shaggy |
| 003 | Pyth | 170707T184855Z | jacoblaw |
| 033 | Python 3 | 170707T160610Z | Simon |
| 007 | Pyth | 170706T214034Z | Jim |
| 005 | Japt | 170706T223014Z | Justin M |
| 017 | Braingolf | 170707T084746Z | Mayube |
| 002 | Jelly | 170706T211023Z | Jonathan |
| 029 | Mathematica | 170706T214639Z | ZaMoC |
| 003 | 170706T221645Z | totallyh | |
| 018 | Python 3 | 170706T214501Z | DJMcMayh |
| 005 | Pip | 170706T215057Z | DLosc |
| 005 | V | 170706T210016Z | DJMcMayh |
| 016 | Haskell | 170706T213038Z | bartavel |
| 045 | PHP | 170706T211019Z | Jör |
| 003 | 05AB1E | 170706T210704Z | Emigna |
JavaScript (ES6), 17 bytes
Takes input as an array of strings.
a=>a.sort()[0][0]
Try it
Input a comma separated list of numbers.
o.innerText=(f=
a=>a.sort()[0][0]
)((i.value="1278,232,98273,2334").split`,`);oninput=_=>o.innerText=f(i.value.split`,`)
<input id=i><pre id=o>
Pyth, 3 bytes
hhS
Input is list of string representations of numbers.
Explanation:
hhS
# Q=input
S # Sort Q
h # First Element of sorted list
h # First element of string
# Implicitly print result
Python 3, 33 bytes
lambda l:min(str(x)[0]for x in l)
@DJMcMayhem and @totallyhuman have a better solutions but mine assumes numerical input instead of string.
Pyth, 9 7 bytes
hSmsh`d
Explanation
This basically return the smallest leading digit.
Q # Implicit input
msh`d # For each number in Q, convert to string, take the first character, convert to integer
hS # Return the minimum
Japt, 8 6 5 bytes
-1 byte thanks to @Shaggy
n g g
Takes input as an array of numeric strings. Try it online!
Explanation
// implicit input: array of strings
n // sort the array
g // get the first element
g // get the first character
// implicit output
Braingolf, 17 bytes
VVR{Mvd<M&$_R}vvx
Explanation
VVR{Mvd<M&$_R}vvx Implicit input from commandline args
VVR Create stack2 and stack3, return to stack1
{.........} Foreach item in stack..
M ..Move item to next stack
v ..Switch to next stack
d ..Split item into digits
<M ..Move first item to next stack
&$_ ..Clear stack
R ..Return to stack1
vv Switch to stack3
x Reduce to lowest value
Implicit output of last item on stack
In other words, it constructs a stack consisting of only the first digit of each item, then outputs the lowest.
This challenge gave me a bunch of useful ideas for builtins to add to Braingolf, and now thanks to the addition of the "special" foreach loop, Braingolf can do it in 5 bytes:
Braingolf, 5 bytes [non-competing]
(d<)x
Explanation
(d<)x Implicit input from commandline args
(..) Special foreach loop, iterates over the stack, moving each item to a special
Sandboxed stack environment, and prepends the last item of the sandboxed
stack to the real stack at the end of each iteration
d< Split into digits, move first digit to end of stack
x Reduce to lowest value
Implicit output of last item on stack
I'm normally against adding builtins just to complete one challenge, but I can see a plethora of uses for the new (...) foreach loop, so I don't really consider it adding a feature just for this challenge.
Jelly, 3 2 bytes
ṂḢ
A full program which takes a list of lists of characters (strings) and prints the result.
How?
We just need to return the smallest leading digit...
ṂḢ - Main link: list of lists of characters
Ṃ - minimum (lexicographical ordering ensures this will start with the minimal digit)
Ḣ - head (get that first digit character)
Mathematica, 29 bytes
Min[First@*IntegerDigits/@#]&
,,,, 3 bytes
⫰1⊣
Explanation
⫰1⊣
⫰ pop the whole stack and push the minimum element
1 push 1
⊣ pop the minimum and 1 and push the first character of it
Pip, 5 bytes
Takes the list of input numbers as command-line arguments.
@@SSg
Alternately:
MN@Zg
Explanations
In both programs, g is the list of command-line args.
@@SSg
SS sorts using string comparison, thus putting the numbers with smallest first digits first, regardless of their magnitudes. Unary @ gives the first element of a list or scalar. We apply it twice to get the first digit of the first number after sorting.
g [24 72 491]
SS [24 491 72]
@ 24
@ 2
Alternately:
MN@Zg
Z is zip; its unary version can be used to transpose a list. The first element of the transposed list is a list of the first digits of all the numbers. @ gets that list of digits; MN takes its minimum.
g [24 72 491]
Z [[2 7 4] [4 2 9]]
@ [2 7 4]
MN 2
V, 11, 5 bytes
ÚxV}p
I was making this waaay more complicated than it actually is. This answer simply sorts every line by ASCII values, and then returns the very first character. Since this is kind or a boring answer, here is a more interesting answer that actually implements the algorithm originally described:
V, 11 bytes
òún
/äîä
Lx