Re: Infinite JAPHs?
by dragonchild (Archbishop) on Mar 30, 2005 at 19:16 UTC
|
If you require that a JAPH must be no more than 4 lines of no more than 80 characters each, then there are, at most, 128 (different ASCII characters) ** 320 different ways to write 320 characters (That's equivalent to 2 ** 2240). Since not all JAPHs are exactly 320, the actual maximum limit is the sum of 128 to the N where N varies from 1 to 320. Or, 127 * SUM( 128**N, N:0->319 ) (or SUM(2**(7N+1),N:0-319) - 1). Of course, you can start chipping away at that pretty quickly. I think the shortest JAPH is something like 50 characters, so that becomes your lowest exponent instead of 1. Not all the ASCII characters are usable, and a lot of them are interchangeable in many cases ($x vs. $y, etc), so that drops the 128 quite a bit. Factor in some more fancy math and I suspect the number drops to something like 2 ** 200 (or so). Or, roughly, 10 ** 66-ish.
In other words, if every possible JAPH were written, one per second, from now onwards, you'd run out of hydrogen in the Sun long before running out of JAPHs. Or, put it another way, if you were to write one JAPH per second from the Big Bang onwards, you'd run out of Universe before you run out of JAPHs.
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
|
print "Just Another Perl Hacker"
Admittedly, not very obfuscated ...
The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. -- Cyrus H. Gordon
| [reply] [d/l] |
|
31!
die"Just Another Perl Hacker\n"
Ok, in fact thats the same length (minus the space), but it has more 'features' (ends with a newline) :-)
--
#!/usr/bin/perl
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
| [reply] [d/l] [select] |
|
|
|
| [reply] |
|
|
>Or, put it another way, if you were to write one JAPH per >second from the Big Bang onwards, you'd run out of >Universe before you run out of JAPHs.
There is a certain comfort in that...
| [reply] |
|
print "Just another Perl hacker,";
print "Just another Perl hacker,";;
print "Just another Perl hacker,";;;
# add more semi-colons as necessary
| [reply] [d/l] |
|
. . . you have immediately demonstrated that there is a finite number of solutions even if the number is large.
Yes, it is a "finite" number, but it is a number that is effectively infinite. For example, 10**10**10**10**10**10**10**10**10**10 is a finite number. Yet, by the 4th 10, you're already past the number of seconds the Universe will survive multiplied by the number of stars in the sky. By the 6th 10, you're past the number of possible living things that will ever live in the Universe, from Big Bang to when it dies, assuming that every 10th star has planets and every 10th such system has a planet that supports life.
You see where I'm going . . .
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
|
|
|
|
|
|
|
|
Well, you forget the condition that the program should be compilable, and, when run, should print "Just another Perl Hacker", (with or without a trailing newline/comma, and with some variation in capitalization). That will drop the number. However, since you can have:
print"Just another Perl Hacker"
(31 characters), you have 4 * 79 - 31 == 285 characters you can use inside comments. If we restrict them to printable characters, that leaves you with 191 characters from the ISO-LATIN-1 character set to use. That will give you:
12431103020403707107438586374215251314062231402740033846271848553839\
64794897942768614366472495245162250622773403971143769094322237777997\
22224034424993652821949360607589486799938766556351642250055325548582\
31176161943484446303420510949249800299598113919038030677551444922891\
92170940375333669061892360087978683497677025806119812237326648034654\
87178777460593657834903959884176099504825209804921507278509975772023\
74764012796271389737610771093408198946475108846474664241214900907612\
62862081852957499464585817808664830865775651649173215474773373760082\
25416891017755307073167219366790883957292361415401836384029334901914\
070048752861187584482256205393168201151
different JAPHs of exactly 4 x 80. Which is about 10**650. | [reply] [d/l] |
Re: Infinite JAPHs?
by cog (Parson) on Mar 30, 2005 at 19:03 UTC
|
$motto = "There is always another way";
$assumption = "There is a way";
$result = combine($motto, $assumption);
print $result;
Prints out "There are two ways";
while (1) {
$result = combine($result, $assumption);
print $result;
}
Prints:
There are three ways
There are four ways
There are five ways
...
The answer, of course, is "Yes" | [reply] [d/l] [select] |
Re: Infinite JAPHs?
by herveus (Prior) on Mar 31, 2005 at 17:27 UTC
|
Howdy!
If we define a JAPH strictly as 'emit the string "Just another Perl hacker\n"'
or something similarly precise (being that I'm too lazy to look up the
canonical form because it's not critical to my proof), then there are an
infinite number of ways to code a JAPH in Perl. Whether that infinity is
countable or not I do not purpose to address.
Proof by induction:
Let the initial program P be:
print "Just another Perl hacker\n"; produces the required output.
If we have a program Q to which we append: 1;
the program's behavior will be unchanged.
Therefore, for any program R that is composed of P followed by any number
of Q, the program RQ continues to produce the desired output.
This produces a nominally infinite sequence of programs that code a JAPH
in Perl, limited only by mere physical limitations of the computer that
is hosting this exercise.
QED (with caveats)
| [reply] [d/l] [select] |
Re: Infinite JAPHs?
by NateTut (Deacon) on Mar 31, 2005 at 19:37 UTC
|
OK then how about the more qualified question "Does there exist an infinite number of non-trivial differing ways to code a JAPH in Perl?" Meaning not just tacking an infinite number of ";"s or "1;"s on the end of print "Just another Perl hacker,";
The question occurred to me because there seems to be an endless supply of different APPROACHES to obscuring the code in a JAPH. Indeed the point of writing one seems to be coming up with a new obfuscation approach. | [reply] |
|
I'd bet that you couldn't actually come up with a number of legal, nontrivial JAPH programs. Based on the fact that it would require you to determine whether a given set of characters from the Perl alphabet would result in not only a well-formed program, but also a program that halts. Because if your JAPH contains a loop/recursion that never halts, then it is not a JAPH. So- You could come up, rather easily, with a number of possible programs, and even reduce that by determining which characters can be placed next to other characters, ie, in english, after you write the letter 'q', you must write the letter 'u'. So, you could calculate the possible number of JAPH's that are wellformed, but not the number of JAPH's that are both wellformed and halt.
| [reply] |
Re: Infinite JAPHs?
by johndageek (Hermit) on Mar 31, 2005 at 14:51 UTC
|
Infinite is an interesting concept. As is finite. The number of grains of sand on earth is finite, but continually changing.
How many ways can “Just Another Perl Hacker” be written?
One way is in ascii, how about as a graphic?
iiiiiii
ii
ii
ii
ii ii
iii
You get the idea.
How about the following:
.--- ..- ... - .- -. --- - .... . .-. .--. . .-. .-.. .... .- -.-.
+ -.- . .-.
So the question is where does finite end?
| [reply] [d/l] [select] |