Hiya,

This JAPH uses the properties of cyclic subgroups to generate a permutation which extracts the JAPH string out of the garbage in the first line.

For the mathematically inclined, the group is Z_29 and the generator is 2.

Kudos to the monk that finds why it doesn't work right on versions less than 5.6.0

Comments, suggestions?

$_=q+juzecsthaghyzrkiererzkntoapl+;$a=$|+ 0xc0ff33-(0xf847*0xc7);sub a{%h=map{$a** $_%qq;${a}9;=>$_}($|..qq.${a}7.);@_=values %h;splice@_,$|,$a.(0xc0de/2/13/211/3+$a) ;}@_=unpack(qq)C*),$_);map{$_=chr$_[$_] ;s}z}\040};s!y!\012!;print;}a(m;japh\););

Replies are listed 'Best First'.
Re: My first JAPH
by Dominus (Parson) on Nov 21, 2000 at 00:57 UTC
    I was a little disappointed that it doesn't actually depend much on the properties of Z29.

    The main place where Z29 appears is in the a() subroutine where you generate a hash %h whose keys are elements of Z29 and whose values are the discrete logarithms of those elements. But then you immediately turn around and use values on %h, which extracts the logs, but not in any mathematically interesting order. The order is determined by the order in which the Z29 elements happen to appear in the Perl hash, which is dependent on the hashing function that Perl uses.

    This is why the program doesn't work except under 5.6.0: The Perl hash function changed in 5.6.0, and the order of the items in the return value of a() depends on this hash function.

      Ah, I see. Thanks for pointing that out.
      I thought that it would return the order in which the elements of Z_29 were found; it seemed to on tests.
      I was interested in the order in which the elements were found, using exponents in ascending order.
      I naively thought this approach would do just that, and eliminate duplicate elements.

      Thanks!
        Says rpc:
        > I thought that it would return the order in which the elements of Z_29 were found
        Nope. Here's what perlfunc has to say about that:
        values HASH
        ...
        The values are returned in an apparently random order. The actual random order is subject to change in future versions of perl...
        so there you go.