# Robbers section

The cops section can be found here.

### Challenge

Your task is to outgolf the submissions of the cops in the same language and the same version (for example, Python 3.5Python 3.4, so that is not allowed). A submission is outgolfed when the length in bytes is shorter than the original submission. You only need to golf off at least 1 byte in order to crack a submission. E.g. if the task was to perform 2 × n, and the submission was the following:

print(2*input())


You could outgolf the cop by doing the following:

print 2*input()


Or even this (since lambda's are allowed):

lambda x:2*x


Post this with the following header:

##{language name}, <s>{prev byte count}</s> {byte count}, {cop's submission + link}


For example:

lambda x:2*x


Computes A005843, (offset = 0).

In that case, you have cracked the submission.

### Scoring

The person with who cracked the most submissions is the winner.

### Rules

• The crack submission must be in the same language as the cop submission.
• The same input should result into the same output (so a(2) = 4 should remain 4).
• For languages such as Python, you can import libraries that are standard included within the language. (So, no numpy/sympy etc.)
• Input and output are both in decimal (base 10).

Note

This challenge is finished. The winner of the Robbers section is feersum. The final scores for the CnR are shown below:

• feersum: 16 cracks
• Dennis: 12 cracks
• Leaky Nun: 6 cracks
• Lynn: 4 cracks
• miles: 3 cracks
• Martin Ender: 2 cracks
• Emigna: 2 cracks
• jimmy23013: 1 crack
• Sp3000: 1 crack
• randomra: 1 crack
• alephalpha: 1 crack
• nimi: 1 crack
• Destructible Watermelon: 1 crack
• Dom Hastings: 1 crack

## Cheddar, 7 6 bytes, Downgoat

(<<)&1


This seems to work, but it's always possible that I don't understand the language correctly.

• Alternatively, (**)&2. I tried 2&(**) and failed. :( – Dennis Aug 7 '16 at 4:19
• @Dennis (**)&2 works just fine for me :/ but this also works. – Downgoat Aug 7 '16 at 5:12

# Jelly, 5 4 bytes, George V. Williams

RÆḊḞ


Try it here.

A hidden feature!

If I remembered correctly, ÆḊ(A) = sqrt(det(AAT)) is n! times the n dimensional Lebesgue measure of a simplex formed by n input point and the origin in m dimensional space. When n=1 it degenerate to the Euclidean distance. Not that weird after all...

• Right, I did something weird with determinants... So well hidden that I couldn't find it myself! – Dennis Aug 8 '16 at 1:14
• @Dennis I know this because someday I tried to extend determinant too, and that's what you get if you want it to work as cross product. But it took me long because I thought it might be weird too and didn't expect someone come up with the same thing... – jimmy23013 Aug 8 '16 at 1:21
• Can these really be considered "bytes?" The code points for Ḋ and Ḟ are in the UTF-16 range. That'd make this solution 6 bytes assuming heterogeneous encoding, and 8 bytes assuming homogeneous encoding. Asking honestly here. – Jules Aug 9 '16 at 18:44
• – jimmy23013 Aug 9 '16 at 19:14

## Hexagony, 91 33 bytes, Blue

1""?{\>{+/</+'+./_'..@'~&/!}'+=($ Unfolded:  1 " " ? { \ > { + / < / + ' + . / _ ' . . @ ' ~ & / ! } ' + = ($
. . . .


Try it online!

Still looks somewhat golfable but I figured I'd post it before FryAmTheEggman beats me to it. ;)

### Explanation

Here are some colour-coded execution paths:

However, these are unnecessarily convoluted due to golfing. Here is the exact same code with a saner layout:

That's better. And finally, here is a memory diagram, where the red arrow indicates the initial position and orientation of the memory pointer (MP):

The gist is that I'm iteratively computing Fibonacci numbers on the three edges labelled f(i), f(i+1) and f(i+2) while keeping track of the iterator on the edges A, B and C. While doing so the roles of these edges are swapped out cyclically after each iteration. Let's see how this happens...

The code starts on the grey path which does some initial setup. Note that f(i) already has its correct initial value of 0.

1   Set edge f(i+1) to 1.
""  Move the MP to edge A.
?   Read input n into edge A.
)   Increment n.


Now the green path is the main loop. _ and > are just mirrors.

(     Decrement n.
<     If the result is zero or less, continue on the red path, otherwise
perform another iteration of the main loop.
{     Move the MP to edge f(i+2).
+     Add edges f(i) and f(i+1) into this edge, computing the next Fibonacci number.
'     Move the MP to the edge opposite A.
~     Multiply by -1 to ensure that it's non-positive (the edge may have a positive
value after a few iterations).
&     Copy the current value of n from A.
'     Move back and to the right again.
+     Copy n by adding it to zero. Since we know that the other adjacent edge
is always zero, we no longer need to use ~&.
'+'+  Repeat the process twice, moving n all the way from A to B.
=     Reverse the orientation of the MP so that it points at f(i) which now
becomes f(i+2) for the next iteration.


This way, the MP moves around the inner triplet of edges, computing successive Fibonacci numbers until n reaches zero. Then finally the red path is executed:

{}    Move the MP to f(i).
!     Print it.
@     Terminate the program.


Diagrams generated with Timwi's HexagonyColorer and EsotericIDE.

• Holy cow! I was expecting to be beaten by you but not my that much! 0.o – Blue Aug 7 '16 at 20:43
• @Blue Are you planning to add an explanation to yours? I'd be interested in how that one works. :) I'll add an explanation to this one as well sooner or later, but I'm not sure I'll find the time today. – Martin Ender Aug 7 '16 at 20:47
• Yeah, mine uses a more traditional method of calculation. I completely forgot about &, that could have saved some bytes – Blue Aug 7 '16 at 20:51

# Haskell, 5 4 bytes, xnor

(^)1


Simple currying.

## Stack Cats, 14 13 bytes, feersum

^]T{_+:}_


with the -nm flags for +4 bytes. Try it online!

Okay, that loop was nuts. I tried several approaches, such as brute forcing over a reduced alphabet and brute forcing 3x+2 or 5x+4 and trying to extend it, but I never expected the solution to actually contain a loop.

The best way to see how this works is to add a D flag for debugging (so run with -nmD) and turn debug on for the above TIO link. A {} loop remembers the top of stack at the beginning of the loop, and exits when the top of stack is that value again. The interior of the loop does some fun subtracting and cycling of the top three elements of the stack, which is how the loop gets to run for so many iterations.

# Sesos, 14 11 bytes, Leaky Nun

Computes n2. Try it here.

Hex dump:

0000000: 16c0f7 959d9b 26e83e ce3d                         ......&.>.=


From assembly:

set numin
set numout
get
jmp
jmp, sub 1, fwd 1, add 1, fwd 1, add 2, rwd 2, jnz
fwd 2, sub 1
rwd 1, sub 1
jmp, sub 1, rwd 1, add 1, fwd 1, jnz
rwd 1
jnz
fwd 2
put

• Nice, you're even shorter than my original golfed version. – Leaky Nun Aug 6 '16 at 11:34
• This computes 1 + 3 + … + (2n–1) instead of n × n :) – Lynn Aug 6 '16 at 11:35
• I also used your approach – Leaky Nun Aug 6 '16 at 11:36

## Woefully, 776 759 bytes, Destructible Watermelon

| |||||||| | |
|| |||||| |
||| |||| |
|||| || |
||||| || |
|||| |||| |
||| |||||| |
|| |||||||| |
| |||||||||| |
|| |||||||| |
||| ||||||| |
||||||||||| |
||||||||||| |
||||||||||| |
||||||||||| |
|||||||||| |
||||||||| |
||||||||| |
||||||||| |
||||||||| |
|||||||||| |
||||||||||| |
|||||||||||| |
||||||||||| |
|||||||||| |
||||||||| |
|||||||| |
||||||| |
|||||| |
||||| |
|||| |
||| |
|| |
| |
| |
| |
|| |
|| |
|| |
|| |
|| |
| |
| |
| |
|| |
||| |
|||| |
||||| |
|||||| |
||||||| |
|||||| |
||||||| |
|||||||| |
||||||||| |
|||||||||| |
||||||||||| |
|||||||||||| |
||||||||||| |
|||||||||| |
||||||||| |
|||||||| |
||||||| |
|||||| |
||||| |
|||| |
||| |
|| |
| |
| |
| |
| |
|| |
| |
|| |
||| |
||| |
|||| |
||| |
|| |
| |
| |
| |
|| |
|| |
|| |
|| |


I tried to read the source code for this language but it was too confusing. For one thing, ip[1] is a line number while ip[0] is the column number, while the cp coordinates are used the other way around. Yet, sometimes the value of cp is assigned to ip. I gave up on trying to understand what the program is doing and found a way to encode the identical sequence of instructions using fewer bars.

# Brachylog, 27 21 bytes, Fatalize

yrb:1a:+a:[1]c*.
:2/.


Try it online!

• Well done! Using integer division is definitely not the solution I had in mind (which is still shorter), didn't even think about it tbh :p – Fatalize Aug 6 '16 at 18:38

# J, 17 12 bytes, miles

+/@(]!2*-)i:


Pretty much the same as the original just more golfed. :)

i: having +1 range compared to i. is useful (and weird). If you use i. here n=0 will be incorrect but luckily i: solves that.

Try it online here.

• Neat trick with i: being zeros for negative values. My version was +/@(]!2*-)i.,]. – miles Aug 6 '16 at 21:03

# M, 10 6 bytes, Dennis

R×\³¡Ṫ


Given n, it computes the nth-level factorial of n. This was a fun exercise!

The code is capable of running as Jelly so you can Try it online.

## Explanation

R×\³¡Ṫ  Input: n
R       Create the range [1, 2, ..., n]
³¡   Repeat n times starting with that range
×\       Find the cumulative products
Ṫ  Get the last value in the list
Return implicitly


# Snowman, 50 44 bytes, Doorknob

((}#2nMNdE0nR1wRaC2aGaZ::nM;aF;aM:nS;aF*))


Try it online!

• Very nice. Even shorter than the original, which was ((}#1nG|#2nMNdE0nR2aGaZ::nM;aF;aM:nS;aF,nM*)). – Doorknob Aug 10 '16 at 16:00

## Haskell, 15 14 bytes, xnor

until odd succ


I spent a fruitless couple of hours learning to decipher "pointless" syntax... until I found this instead.

Or for a less mellifluous 13 bytes, until odd(+1).

• Nicely done, this is what I had in mind. I like the three words. – xnor Sep 8 '16 at 2:28

## Python 2, 43 40, xsot

g=lambda n:n<2or-~sum(map(g,range(n)))/3

• Interesting, this is different from what I had originally. – xsot Aug 7 '16 at 0:23

# Pyke, 11 9 bytes, muddyfish

hVoeX*oe+


Try it here!

### How it works

          Implicit input: n (accumulator), n (iterations)
h         Increment the number of iterations.
V        Do the following n + 1 times.
o         Iterator. Pushes its value (initially 0) and increments it.
e        Perform integer division by 2.
This pushes 0 the first time, then 1, then 2, etc.
X       Square the result.
*      Multiply the accumulator and the result.
oe    As before.
+   Add the result to the accumulator.
This sets the accumulator to a(0) = 0 in the first iteration and
applies the recursive formula in all subsequent ones.

• Using that method you can get 8 with hV~oX*o+. My 5 byte answer was SDmX^ – Blue Aug 8 '16 at 5:39
• Ah, ~o is neat. I have no idea what SDmX^ does though. – Dennis Aug 8 '16 at 5:48
• It basically uses mixed base conversation on the 1-indexed range against that squared. Not something on OEIS – Blue Aug 8 '16 at 5:50
• Oh, does m only affect the X and not the ^? That explains a lot. – Dennis Aug 8 '16 at 5:53
• Yeah, m and similar only use the next node. Any comments on my docs etc? – Blue Aug 8 '16 at 5:55

## 05AB1E, 7 4, Emigna

LnOx


From the formula for the sum of squares of positive integers 1^2 + 2^2 + 3^2 + ... + n^2 = n(n+1)(2*n+1)/6, if we multiply both sides by 2 we get Sum_{k=0..n} 2*k^2 = n(n+1)(2*n+1)/3, which is an alternative formula for this sequence. - Mike Warburton (mikewarb(AT)gmail.com), Sep 08 2007

• I'm happy you cracked it at 4 since there was a trivial modification of my public one I'd missed. Nice! – Emigna Aug 8 '16 at 12:59

## Jelly, 22 21 bytes, Dennis

_²×c×Ḥc¥@÷⁸÷’{S
‘µR+ç


I spent several hours reading Jelly source code for the last one, so I might as well put this "skill" to use. I hope @Dennis will share with us his mathematical discoveries allowing a shorter formula (assuming there is something and not only weird Jelly tricks!).

• For comparison, I had: ‘Ḥc_×c@+¥\nr0ç@€:‘+\S – Sp3000 Aug 19 '16 at 19:07
• @Sp3000 Oh, well why didn't you post it? – feersum Aug 19 '16 at 19:40
• More time to think about the 6 before Dennis reposts in M :P – Sp3000 Aug 19 '16 at 20:10

# J, 20 19 bytes, miles

[:+/2^~+/@(!|.)\@i.


This computes the product as a sum of squared Fibonacci numbers, which are calculated as a sum of binomial coefficients.

Thankfully, @miles himself posted the code to generate Fibonacci numbers in this comment.

# Acc!!, 526 525 bytes, DLosc

N
Count x while _%60-46 {
(_+_%60*5-288)*10+N
}
_/60
Count i while _/27^i {
_+27^i*(_/27^i*26-18)
}
_*3+93
Count i while _/27^i/27%3 {
_-i%2*2+1
Count j while _/3^(3*j+2-i%2)%3 {
_+3^(1+i%2)
Count k while _/3^(3*k+1+i%2)%3-1 {
_+3^(3*k+1+i%2)*26
}
}
}
Count i while _/27^i/3 {
_-_/27^i/3%27*27^i*3+_/3^(3*i+1+_%3)%3*3
}
_/3
Count i while _/100^i {
_*10-(_%100^i)*9
}
Count i while _/100^i/10 {
_+_/100^i/10%10
Count j while i+1-j {
_+(_%10-_/100^(j+1)%10)*(100^(j+1)-1)
}
}
_/100
Count j while _/100^j {
Write _/100^j%10+48
}


I have no idea how this works, but I was able to spot a tiny improvement.

24c24
< _+_/100^i*100^i*9
---
> _*10-(_%100^i)*9

• Ah, shoot. I was hoping no one would catch a math golf that I missed. +1 – DLosc Aug 20 '16 at 22:34

gcd=<<(2^)


Usage example: map ( gcd=<<(2^) ) [1..17] -> [1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,16,1].

How it works: From the oeis page we see that a(n) = gcd(2^n, n) or written in Haskell syntax: a n = gcd (2^n) n. Functions with the pattern f x = g (h x) x can be turned to point-free via the function =<<: f = g =<< h, hence gcd=<<(2^) which translates back to gcd (2^x) x.

• ............... How – TuxCrafting Oct 22 '16 at 23:12

# Sesos, 14 9 bytes, Leaky Nun

Computes n mod 16. Try it here.

Hex:

0000000: 17f84a 750e4a 7d9d0f                              ..Ju.J}..


Assembly:

set numin
set numout
get
jmp, sub 1, fwd 1, add 16, rwd 1, jnz
fwd 1
jmp, sub 16, fwd 1, add 1, rwd 1, jnz
fwd 1
put

• This is precisely my solution :D – Leaky Nun Aug 6 '16 at 12:03

# Python, 39 17 bytes, Destructible Watermelon

lambda n:n*-~n>>1

• actually really good, I'm actually glad at being outgolfed to see this solution – Destructible Lemon Aug 6 '16 at 12:17
• Why complicate a simple formula with the right shift? – xsot Aug 6 '16 at 12:29
• @xsot Because I didn't know what version he used. – Leaky Nun Aug 6 '16 at 12:54

# 05AB1E, 9 4 bytes, Emigna

>n4÷


Try it online!

## Hexagony, 7 6 bytes, Adnan

?!/$(@  Unfolded:  ? ! /$ (
@ .


Try it online!

Same idea, slightly different layout.

• Ahhh, very nice! That was exactly the same solution :). – Adnan Aug 6 '16 at 15:28

## MATL, 11 10 bytes, Luis Mendo

YftdAwg_p*


Instead of doing -1^length(array) it converts the elements to Boolean values (which are always 1), negates them, and takes the product of the elements.

# Jelly, 11 10, Dennis

Ḥ’_Rc’*@RP


Vectorized version of same approach.

Try it online!

# 05AB1E, 10 8 bytes, Adnan

µNÂÂQ>i¼

• Yeah, that was pretty dumb of me :p. I forgot that that has been an actual challenge. – Adnan Aug 7 '16 at 19:04
• µNÂÊ½ for 5 bytes. Presumably the secret version. – Emigna Aug 7 '16 at 21:06

# Brachylog, 11 10 bytes, Fatalize

yb:AcLrLc.


Try it online!

## Explanation

Brachylog is a Prolog-derived languages, whose greatest ability is to prove things.

Here, we prove these statements:

yb:AcLrLc.
yb:AcL       Inclusive range from 1 to input, concatenated with A, gives L
LrL     L reversed is still L
Lc.   L concatenated is output

• This is exacly the answer I had in mind, well done! – Fatalize Aug 10 '16 at 7:53

# Jelly, 9 8 bytes, Dennis

œċr0$L€Ḅ  Sorry! I wasn't able to find your intended solution. This relies on the fact that C(n+k-1, k) is the number of ways to choose k values from n with replacement. Note: This is inefficient since it generates the possible sets in order to count them, so try to avoid using large values of n online. I later found another 8 byte version that is efficient enough to compute n = 1000. This computes the values using the binomial coefficient and avoids generating the lists. Ḷ+c’Ṛ;1Ḅ  ## Explanation œċr0$L€Ḅ  Input: n
r0\$     Create a range [n, n-1, ..., 0]
œċ        Create all combinations with replacement for
(n, n), (n, n-1), ..., (n, 0)
L€   Find the length of each
Ḅ  Convert it from binary to decimal and return

Ḷ+c’Ṛ;1Ḅ  Input: n
Ḷ         Creates the range [0, 1, ..., n-1]
+        Add n to each in that range
’      Get n-1
c       Compute the binomial coefficients between each
Ṛ     Reverse the values
;1   Append 1 to it
Ḅ  Convert it from binary to decimal and return


## M, 9 8 bytes, Dennis​

Ḥrc’ḊḄḤ‘

• Nice idea with the double + increment – miles Aug 14 '16 at 8:40

## QBasic, 30 29 bytes, DLosc

INPUT n:?(n MOD 2)*(n+.5)+n/2
`
• Nice! (Though not quite what I had.) – DLosc Aug 19 '16 at 20:43