Skip to main content
Commonmark migration
Source Link

#J, 22 bytes

J, 22 bytes

-6 bytes thanks to frownyfrog

I.~0+/\@,1%2*1+[:i.9&^

Try it online!

##original answer

original answer

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

#J, 22 bytes

-6 bytes thanks to frownyfrog

I.~0+/\@,1%2*1+[:i.9&^

Try it online!

##original answer

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

J, 22 bytes

-6 bytes thanks to frownyfrog

I.~0+/\@,1%2*1+[:i.9&^

Try it online!

original answer

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

added 238 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

#J, 2822 bytes

-6 bytes thanks to frownyfrog

I.~0+/\@,1%2*1+[:i.9&^

Try it online!

##original answer

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

#J, 28 bytes

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

#J, 22 bytes

-6 bytes thanks to frownyfrog

I.~0+/\@,1%2*1+[:i.9&^

Try it online!

##original answer

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

added 360 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

#J, 28 bytes

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

#J, 28 bytes

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Try it online!

#J, 28 bytes

Luis's answer in J:

1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed

1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)

Explanation

1 +      NB. 1 plus... 
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to 
9&^      NB. 9 raised to the power of the arg

Try it online!

Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94
Loading