Problems? Is your data what you think it is? PerlMonks

nothing as it seems...

by jynx (Priest)
 on Mar 27, 2001 at 04:16 UTC Need Help??

```#!/usr/bin/perl
# This is one of my favorite algorithms, put to perl use.
# Run it on command line with no arguments to see what i
# mean.  Feed it numbers for a bit of a spoiler.

\$==\$ARGV[0]||67;(\$j,@p)=(0,1,2);while(\$=>=@p-1){\$h=1;{\$p=\$h**2+\$h+\$p[\$
+j];
@p=b(@p,\$p)if i(\$p);\$h++;redo if \$h<\$p[\$j]-1;}\$j++}shift @p;unless(@AR
+GV){
@f=@p[1,2,6,23,24,25,27];@f=(\$f[2]+\$f[3],\$f[4],\$f[1]+\$f[6],\$f[0]+\$f[5]
+);
\$f[\$_]=chr(\$f[\$_])foreach(0..\$#f);\$.=join '',@f;\$..=\$/;die \$.}foreach(
+@p){
print "\$_ ";print "\n" unless(++\$t%10)}print "\n";sub i{(\$%,\$*,\$n)=
(+shift,1,1);{(\$n-- and last) unless \$%%\$p[\$*];last if \$p[\$*]**2>\$%-1;
\$*++ and redo}\$n}sub b{\$_{\$_}++ foreach(@_);sort{\$a<=>\$b}keys %_}

#nuf evah,
#jynx
#
# PS please tell me what you think, areas of improvement, etc...

Replies are listed 'Best First'.
Re: nothing as it seems...
by jynx (Priest) on Mar 29, 2001 at 03:54 UTC

After much time has passed:

i read somewhere that a japh is supposed to fit on 4 lines or less. Hmmm, i didn't know that when i first posted this. In deference to the rules, here is an updated version. The output has changed tremendously, and is now only useful if piped to a file :(

```#!/usr/local/bin/perl

(\$j,\$a,\$p,@h)=(\$ARGV[0]||68,-1,1,1,2);for(;\$j>@h;){\$==1;\$a++;do{do{\$;=
+1;\$_==\$
p&&next,(\$*=\$=**2+\$=+\$h[\$a])%\$_ or\$;=0,\$_**2>\$*-1&&last for@h;\$;}?@h=s
+ort{\$a
<=>\$b}keys%{{map{\$_,1}@h,\$=**2+\$=+\$h[\$a]}}:8}while++\$=<\$h[\$a]-1}shift@
+h;print
!@ARGV?map{chr}\$h[23]+\$h[6],\$h[24],\$h[2]+\$h[27],\$h[1]+\$h[25]:(map\$_.\$/
+,@h),\$/
jynx

Create A New User
Node Status?
node history
Node Type: obfuscated [id://67395]
Approved by root
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-10-23 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My fridge is mostly full of:

Results (277 votes). Check out past polls.

Notices?