Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

drunk programming

Name: Anonymous 2012-04-16 20:32

do you?

how efficient are you?

how legible is your code?

do you remember what you intended to do the next day?

Name: Anonymous 2012-04-17 1:38

i solved one of the simpler euler problems after getting stoned, but im pretty sure i did it the nigger way (keep in mind, im a new programmer):

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.


public class Problem2
{
    public static void main (String[] args)
    {
        for(int x = 800; x < 1000; x++)
        {
            for(int y = 800; y < 1000; y++)
            {
                int prod = x * y;
                String pStr = Integer.toString(prod);
               
                if(pStr.charAt(0) == pStr.charAt(5))
                {
                    if(pStr.charAt(1) == pStr.charAt(4))
                    {
                        if(pStr.charAt(2) == pStr.charAt(3))
                        {
                            System.out.println(prod);
                        }
                    }
                }
            }
        }

    }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List