Author |
Topic: Java class p (Read 926 times) |
|
Grimbal
wu::riddles Moderator Uberpuzzler
Gender:
Posts: 7527
|
|
Java class p
« on: May 23rd, 2004, 1:47pm » |
Quote Modify
|
Java is a beautiful language. You have a package p, a class p in that package, the constructor p() for the class, a method p() and a variable p. Here is a simple(!) class. What does it do, and how? Code:package p; class p { int p; p p(p p) { return new p() { p p(p p) { this.p++; return p; } }; } p p() { return new p() { p p(final p q) { return new p() { p p(p p){ return p.this.p(q).p(q.p(p)); } }; } }; } public String toString(){ p p = new p(); p = p.p(p); return "" + p(p).p(p).p; } public static void main(String[] args) { p q = new p(); for( int j=0 ; j<=6 ; j++ ){ p p = new p(); for( int i=0 ; i<=6 ; i++ ){ System.out.print( p.p(q) + "\t"); p = p.p(); } System.out.println(); q = q.p(); } } } |
|
|
« Last Edit: May 23rd, 2004, 1:55pm by Grimbal » |
IP Logged |
|
|
|
TenaliRaman
Uberpuzzler
I am no special. I am only passionately curious.
Gender:
Posts: 1001
|
|
Re: Java class p
« Reply #2 on: May 24th, 2004, 11:04am » |
Quote Modify
|
what a clumsy code just to find the powers of numbers. i will skip the explanation for now, but a small hinter if anyone trying ::just forget what the program does and try to find what the two overloaded methods p(p) and p() do:: more important hint ::the number of times the function is called is important.so try to break into cases like what happens in first call,in second call and so on::
|
|
IP Logged |
Self discovery comes when a man measures himself against an obstacle - Antoine de Saint Exupery
|
|
|
|