wu :: forums
« wu :: forums - Java class p »

Welcome, Guest. Please Login or Register.
May 19th, 2024, 9:29am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Icarus, Eigenray, Grimbal, SMQ, towr, william wu, ThudnBlunder)
   Java class p
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Java class p  (Read 926 times)
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Java class p  
« on: May 23rd, 2004, 1:47pm »
Quote Quote Modify 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
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Java class p  
« Reply #1 on: May 23rd, 2004, 11:33pm »
Quote Quote Modify Modify

on May 23rd, 2004, 1:47pm, grimbal wrote:
Java is a beautiful language.
I can't say I agree
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
TenaliRaman
Uberpuzzler
*****



I am no special. I am only passionately curious.

   


Gender: male
Posts: 1001
Re: Java class p  
« Reply #2 on: May 24th, 2004, 11:04am »
Quote Quote Modify Modify

what a clumsy code  Grin 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
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board