Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Python, size 15, by mbomb007Python, size 15, by mbomb007

There are at least 5 permutations that work. This is one of them:

`3*.7/50`[::~4]

It was pretty obvious that the original code was something of the form `«expression»`[«range»], so it wasn't difficult to place the backticks, colons and square brackets. On a hunch, I assumed that the range specifier was [::~i] for some value of i, leaving only 8 characters to permute. This took only a fraction of a second. Here's the code I used:

from itertools import permutations

perms = [''.join(p) for p in permutations('03457*./')]
for p in perms:
    try:
        e = '`'+p[:-1]+'`[::~'+p[-1:]+']'
        if eval(e)=='6991':
            print e
    except:
        continue

(The original code is actually a bit flakey, since the result of 3*.7/50 isn't guaranteed to be 0.041999999999999996 all of the time.)

Python, size 15, by mbomb007

There are at least 5 permutations that work. This is one of them:

`3*.7/50`[::~4]

It was pretty obvious that the original code was something of the form `«expression»`[«range»], so it wasn't difficult to place the backticks, colons and square brackets. On a hunch, I assumed that the range specifier was [::~i] for some value of i, leaving only 8 characters to permute. This took only a fraction of a second. Here's the code I used:

from itertools import permutations

perms = [''.join(p) for p in permutations('03457*./')]
for p in perms:
    try:
        e = '`'+p[:-1]+'`[::~'+p[-1:]+']'
        if eval(e)=='6991':
            print e
    except:
        continue

(The original code is actually a bit flakey, since the result of 3*.7/50 isn't guaranteed to be 0.041999999999999996 all of the time.)

Python, size 15, by mbomb007

There are at least 5 permutations that work. This is one of them:

`3*.7/50`[::~4]

It was pretty obvious that the original code was something of the form `«expression»`[«range»], so it wasn't difficult to place the backticks, colons and square brackets. On a hunch, I assumed that the range specifier was [::~i] for some value of i, leaving only 8 characters to permute. This took only a fraction of a second. Here's the code I used:

from itertools import permutations

perms = [''.join(p) for p in permutations('03457*./')]
for p in perms:
    try:
        e = '`'+p[:-1]+'`[::~'+p[-1:]+']'
        if eval(e)=='6991':
            print e
    except:
        continue

(The original code is actually a bit flakey, since the result of 3*.7/50 isn't guaranteed to be 0.041999999999999996 all of the time.)

Source Link
r3mainer
  • 19.7k
  • 7
  • 49
  • 83

Python, size 15, by mbomb007

There are at least 5 permutations that work. This is one of them:

`3*.7/50`[::~4]

It was pretty obvious that the original code was something of the form `«expression»`[«range»], so it wasn't difficult to place the backticks, colons and square brackets. On a hunch, I assumed that the range specifier was [::~i] for some value of i, leaving only 8 characters to permute. This took only a fraction of a second. Here's the code I used:

from itertools import permutations

perms = [''.join(p) for p in permutations('03457*./')]
for p in perms:
    try:
        e = '`'+p[:-1]+'`[::~'+p[-1:]+']'
        if eval(e)=='6991':
            print e
    except:
        continue

(The original code is actually a bit flakey, since the result of 3*.7/50 isn't guaranteed to be 0.041999999999999996 all of the time.)