| Bytes | Lang | Time | Link |
|---|---|---|---|
| 022 | Juby | 250514T193235Z | Jordan |
| 058 | JavaScript | 181028T154802Z | guest271 |
| 008 | Japt | 181024T172012Z | Shaggy |
| 015 | J | 181025T011437Z | Bubbler |
| 053 | Python 2 | 181024T113236Z | lynn |
| 060 | Scala | 181024T222609Z | jrook |
| 053 | Clean | 181024T215148Z | Οurous |
| 004 | Jelly | 181024T200638Z | Jonathan |
| 042 | Haskell | 181024T160934Z | totallyh |
| 052 | Python 2 | 181024T170757Z | ovs |
| 052 | Python 2 | 181024T100055Z | Dead Pos |
| 044 | Python 2 | 181024T133209Z | Dennis |
| 039 | PowerShell | 181024T124334Z | AdmBorkB |
| 060 | Python 2 | 181024T074702Z | ElPedro |
| 043 | JavaScript ES6 | 181024T101421Z | Arnauld |
| 010 | Charcoal | 181024T093212Z | Neil |
| 006 | MathGolf | 181024T081122Z | Jo King |
| 076 | Java JDK | 181024T081053Z | Olivier |
| 004 | 05AB1E | 181024T080008Z | Kevin Cr |
| 006 | Husk | 181024T075639Z | ბიმო |
| 006 | Jelly | 181024T074620Z | ATaco |
JavaScript, 58 bytes
_=>[_.map((_,i)=>t.unshift(++i),t=[]),t].map(_=>+_.join``)
Pass current index of array plus 1 to .unshift() to fill first array with a second array's .length, .join() each resulting array without any characters separating elements and convert to integer. Returns an array of two integers.
Japt, 9 8 bytes
Êõ ¬pÔò¶
Explanation
Ê :Length
õ :Range [1,Ê]
¬ :Join
p :Concatenate
Ô : Reverse
ò :Partition
¶ : Between equal characters
J, 15 bytes
4(,:|.)@u:48+#\
How it works
4(,:|.)@u:48+#\
#\ Generate 1-based indices of given array
48+ Convert digits to ASCII value
4 @u: Convert to string
(,:|.) Append its reverse
Python 2, 53 bytes
n=len(input())+1
b=10**n/81-n/9
print[b,10**n/90*n-b]
For example, for \$n=5\$: \begin{align} 12345 &= 11111 + 1111 + 111 + 11 + 1 \\ &= (11111.\bar1 + 1111.\bar1 + \dots + 1.\bar1) - (0.\bar1 \times 5) \\ &= \frac{10}{9} \left( \sum_{k=0}^{n-1} 10^{k} \right) - \frac n9 \\ &= \frac{10}{9} \left( \frac{1-10^n}{1-10} \right) - \frac{n}{9} \\ &= \frac{10^{n+1}-1}{81}-\frac{n+1}{9} \end{align}
We use integer (floor) division, so the surplus \$\frac{1}{81}\$ gets rounded away.
For the descending part, if b=12345 we compute something like 66666-12345 == 54321.
Jelly, 4 bytes
JṚƬḌ
How?
JṚƬḌ - Link: list L e.g. ['ant','bee','cat','dog','elk','frog']
J - range of length [1,2,3,4,5,6]
Ƭ - 'till (collect up until results are no longer unique):
Ṛ - reverse 1:[6,5,4,3,2,1] , 2:[1,2,3,4,5,6]=1st
- -> [[1,2,3,4,5,6],[6,5,4,3,2,1]]
Ḍ - from base ten [123456,654321]
Python 2, 55 52 bytes
a=''
for i in input():a+=`-~len(a)`
print[a,a[::-1]]
Explanation:
# initial value: empty string
a=''
# iterate over input
# will work with any iterable object: list, tuple, dict, set, string, etc.
for i in input():
# add to a string representation of its length+1
a+=`-~len(a)`
# print list, composed from a and its reversed version
print[a,a[::-1]]
Python 2, 66 bytes
lambda i:`map(abs,range(-len(i),-~len(i)))`[1::3].split('0')[::-1]
Explanation:
lambda i:`map(abs,range(-len(i),-~len(i)))`[1::3].split('0')[::-1]
# unnamed lambda
# example input: ['q', 'w', 'e', 'r', 't']
# create range from minus length of input to length+1
# ['q', 'w', 'e', 'r', 't'] -> [-5,-4,-3,-2,-1,0,1,2,3,4,5]
range(-len(i),-~len(i))
# change every value in range to its absolute value
# [-5,-4,-3,-2,-1,0,1,2,3,4,5] -> [5,4,3,2,1,0,1,2,3,4,5]
map(abs,range(-len(i),-~len(i)))
# get string representaion of list
# [5,4,3,2,1,0,1,2,3,4,5] -> '[5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]'
`map(abs,range(-len(i),-~len(i)))`
# get each third element from string, starting from index 1, returns string
# '[5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]' -> '54321012345'
`map(abs,range(-len(i),-~len(i)))`[1::3]
# split string over '0', returns list of 2 values
# '54321012345' -> ['54321','12345']
`map(abs,range(-len(i),-~len(i)))`[1::3].split('0')
# reverse list
# ['54321','12345'] -> ['12345','54321']
`map(abs,range(-len(i),-~len(i)))`[1::3].split('0')[::-1]
PowerShell, 39 bytes
-join(1..($x=$args.count));-join($x..1)
Takes input via splatting, which on the command-line prompt looks like, e.g., $a=(4,3,2); .\array-to-indices.ps1 @a, and on TIO manifests as separate arguments for each entry.
We take the .count of the input $args, store that into $x. Then construct a range .. from 1 up to $x and -join it into a string. Finally we -join the range the other direction. Those two strings are left on the pipeline and output is implicit.
Python 2, 64 60 bytes
a=''.join(map(str,range(1,-~len(input()))))
print[a,a[::-1]]
-1 with thanks to @KevinCruijssen
-3 with thanks to @DeadPossum
JavaScript (ES6), 43 bytes
Returns an array of 2 strings.
a=>a.map(_=>(a+=++i,b=i+b),i=a=b='')&&[a,b]
Charcoal, 10 bytes
⟦⭆θ⊕κ⮌⭆θ⊕κ
Try it online! Link is to verbose version of code. Explanation:
θ θ Input array
⭆ ⭆ Map over elements and join
κ κ Current index (0-indexed)
⊕ ⊕ Increment
⮌ Reverse
⟦ Collect into an array
MathGolf, 6 bytes
£╒y_xα
£╒y_xα
£ Length of input array
╒ Range from 1 to n
y Join
_x Duplicate and reverse
α Wrap top two elements in array
Java (JDK), 76 bytes
a->{String[]r={"",""};int i=1;for(var x:a){r[1]=i+r[1];r[0]+=i++;}return r;}
05AB1E, 4 bytes
ā‚J
Try it online or verify all test cases.
Explanation:
ā # List in the range [1, length of (implicit) input-list]
# i.e. ["a","e","i","o","u"] → [1,2,3,4,5]
 # Bifurcated (short for Duplicate & Reverse copy)
‚ # Pair both list into a single list of lists
# i.e. [1,2,3,4,5] and [5,4,3,2,1] → [[1,2,3,4,5],[5,4,3,2,1]]
J # Join the individual items of the inner lists together (and output implicitly)
# i.e. [[1,2,3,4,5],[5,4,3,2,1]] → ["12345","54321"]
Husk, 6 bytes
S¤,d↔ŀ
Explanation
S¤,d↔ŀ -- input xs (list)
ŀ -- indices [1..length xs]
S ↔ -- do the following with itself and itself reversed:
¤,d -- | undigits and join as tuple
Jelly, 6 bytes
J,JṚ$Ḍ
Explanation
J # Converts an array to [1, ...len(arr)]
, # Paired with
JṚ$ # The same array as before, reversed.
Ḍ # Convert the digits to integers.
I'm no Jelly master, so likely sub-optimal.