Python 2, 180 bytesCracked
My solution
So now that xnor has cracked it in a way I am sufficiently satisfied with I am going to reveal my solution
r,o:(o and f(~(~r&~o)&~(r&o),int(`r`[:r&~r].join([`dict()`[r&~r],`r&~r`,`dict([(r&~r,r&~r)])`[int(`~([]in[[]])`[[]in[[]]:])],`min`[[]in[[]]],`dict()`[~(r&~r)],`r&~r`]).format(r&o),int(`~([]in[[]])`[[]in[[]]:]))))or r
Surprise, surprise its a hulking pile of gibberish. Rather than break this down I'm going to go through the process of how I made this.
I started with a pretty standard addition algorithm
r,o:(o and f(r^o,r&o<<1))or r
Then I used a bitwise trick for representing ^
with |
,&
,~
.
r,o:(o and f((r|o)&~(r&o),r&o<<1))or r
I used another bitwise trick to get rid of the |
r,o:(o and f(~(~r&~o)&~(r&o),r&o<<1))or r
Now all thats left is the <<
, shouldn't be too hard, right? Well get ready for a bumpy ride. To replace the bitshift I used strings to append a zero to the end of its binary representation
r,o:(o and f(~(~r&~o)&~(r&o),int(bin(r&o)[2:]+"0",2)))or r
This has a few problems but the primary one is using addition, so I worked around this by using a format instead
r,o:(o and f(~(~r&~o)&~(r&o),int("{}0".format(bin(r&o)[2:]),2)))or r
We are not allowed to use bin, so I used string formatting to convert to binary.
r,o:(o and f(~(~r&~o)&~(r&o),int("{0:b}0".format(r&o),2)))or r
Since string literals are forbidden I have to build the string {0:b}0
out of parts made with back ticks and join
them together.
r,o:(o and f(~(~r&~o)&~(r&o),int("".join(["{","0",":","b","}","0"]).format(r&o),2)))or r
The empty string is pretty easy, you can just do
`r`[:0]
The zeros were
`0`
and the {:}
were all grabbed from dictionaries.
r,o:(o and f(~(~r&~o)&~(r&o),int("".join([`dict()`[0],`0`,`dict([(0,0)])`[2],"b",`dict()`[-1],`0`]).format(r&o),2)))or r
b
seems pretty hard to get, its not in our character set, so how are we supposed to get an object that has a b
in its repr
? Well here's how: When you use repr
on a builtin function you get something that looks like
<built-in function name>
And thats from where we'll get our b
.
r,o:(o and f(~(~r&~o)&~(r&o),int("".join([`dict()`[0],`0`,`dict([(0,0)])`[2],`min`[1],`dict()`[-1],`0`]).format(r&o),2)))or r
Now all thats left are numbers, I only need -1, 0, 1, and 2 so here's how I represented them:
-1 = ~(r&~r)
0 = r&~r
1 = []in[[]]
2 = `~([]in[[]])`[[]in[[]]:]
2 could actually be a byte shorter as
```r&~r```.find(`r&~r`)
based on @Blender's suggestions in the comments, but I didn't think of this until after the fact.
So we substitute these numbers in
r,o:(o and f(~(~r&~o)&~(r&o),int(`r`[:r&~r].join([`dict()`[r&~r],`r&~r`,`dict([(r&~r,r&~r)])`[int(`~([]in[[]])`[[]in[[]]:])],`min`[[]in[[]]],`dict()`[~(r&~r)],`r&~r`]).format(r&o),int(`~([]in[[]])`[[]in[[]]:]))))or r
And thats the crack.