Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^2: what is for key pls

by wind (Priest)
on May 11, 2011 at 02:26 UTC ( #904067=note: print w/replies, xml ) Need Help??

in reply to Re: what is for key pls
in thread what is for key pls

I made a quick and dirty script to see if some combination of + and -'s between all the digits of that string would return 42.

my $str = '7c9695cb23a71d851688cc0d7f8b1072'; my @nums = map {hex} split '', $str; my @ops = qw(+ -); my @iter = (0) x (length($str) - 1); MAIN: while (1) { my @set = (@ops[@iter], ''); my $newstr = join '', map {$nums[$_] . $set[$_]} (0..$#nums); print "$newstr\n" if 42 == eval $newstr; # Increment my $i = $#iter; while (++$iter[$i] == @ops) { $iter[$i--] = 0; last MAIN if $i < 0; } }

After running for an hour though, I decided that I needed to test this by hand:

use List::Util qw(sum); my $str = '7c9695cb23a71d851688cc0d7f8b1072'; print sum map {hex} split '', $str; =prints 231 =cut

Unfortunately, as you can see, the string contains an odd number of odd digits. This means that no combination of + and -'s between all the digits can return an even number. So there is no simple solution that equals 42

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://904067]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2018-02-25 02:15 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.