Forum Home
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular

    The First Drunken Code Contest (Java) - Win 10 FTC \[FINISHED\]

    Off-Topic
    10
    26
    6904
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kevlar Spammer last edited by

      [quote name=“adamstgbit” post=“48329” timestamp=“1388372067”]
      is the answer for #2 bubble sort?
      [/quote]

      Nope.

      [quote]
      is it sorting the numbers? i can’t tell the code is purposely confusing
      [/quote]

      Well I was drunk when I wrote it! Why don’t you run the code and find out?

      1 Reply Last reply Reply Quote 0
      • D
        delimitri last edited by

        [quote name=“Kevlar” post=“48193” timestamp=“1388323454”]
        Welcome! I’m drunk, and writing code. I’ll give 10 FTC to the first person who can tell me the following:

        1. What does this code do?
        2. How does it do it?
        3. How would I do this if I was sotally tober?

        [code]
        package totally.awesome;

        import java.awt.List;
        import java.io.BufferedReader;
        import java.io.IOException;
        import java.io.InputStreamReader;
        import java.util.Random;

        import org.joda.time.DateTime;
        import org.joda.time.Interval;

        public class ImASexGod {
        private static final Random RANDOM = new Random();

        public static void main(String[] args) {

        List doubleList = new java.awt.List();

        System.out.print(“Enter numbers until you’re awesome.”);

        // open up standard input
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input = null;

        do{//her
        try {//it once
        input = br.readLine();
        } catch (IOException ioe) {
        System.out.println(“Dude, that’s not awesome!”);
        System.exit(1);
        }

        try {//it you’ll like it
        double d = Double.parseDouble(input);
        doubleList.add(input);
        } catch (NumberFormatException e) {
        if (!input.equals(“”)) System.out.println(“Only numbers are allowed. I’m a number nazi.”);
        }

        } while (!input.equals(“”));

        printCurrentListAndStuff(doubleList);

        while (isBetterBest(doubleList) < doubleList.getItemCount()){
        List newlist = createSomething(doubleList);

        //oh man this is awesome
        //this must be where the awesome happens
        if (isBetterBest(doubleList)

        1 Reply Last reply Reply Quote 0
        • zerodrama
          zerodrama Regular Member last edited by

          Too tired right now, but obviously it’s a number snorter and it has lines of code.

          Back soon.

          1 Reply Last reply Reply Quote 0
          • K
            Kevlar Spammer last edited by

            And ZD WINS!!! Congrats. Very well done.

            One might call this a Monte-Carlo sort. It uses evolution to arrive at a perfectly sorted list by following this algorithm:

            1. Get a list of numbers.
            2. Randomly reorder the numbers in the list.
            3. See if this list is “more” sorted than the last one.
            4. If it’s perfectly sorted, we’re done.
            5. If it’s better, use it as the new list, and go to step 2.
            6. If it’s worse, throw it out and go back to step 2.

            This is, obviously, highly inefficient and a huge waste of time and code to accomplish something that could be done using a lot less work.

            The correct code to do this, as ZD correctly pointed out is with the one line of code: Collections.sort(list)

            FTC will be sent tonight. Stay tuned for the next Drunken Coding Challenge!

            1 Reply Last reply Reply Quote 0
            • D
              delimitri last edited by

              [quote name=“Kevlar” post=“48454” timestamp=“1388430164”]
              And ZD WINS!!! Congrats. Very well done.

              One might call this a Monte-Carlo sort. It uses evolution to arrive at a perfectly sorted list by following this algorithm:

              1. Get a list of numbers.
              2. Randomly reorder the numbers in the list.
              3. See if this list is “more” sorted than the last one.
              4. If it’s perfectly sorted, we’re done.
              5. If it’s better, use it as the new list, and go to step 2.
              6. If it’s worse, throw it out and go back to step 2.

              This is, obviously, highly inefficient and a huge waste of time and code to accomplish something that could be done using a lot less work.

              The correct code to do this, as ZD correctly pointed out is with the one line of code: Collections.sort(list)

              FTC will be sent tonight. Stay tuned for the next Drunken Coding Challenge!
              [/quote]

              I might be blind, but it looks like ZD went to sleep.
              Wasn’t that my answer that mentioned Collections.sort(listName)? :o

              1 Reply Last reply Reply Quote 0
              • K
                Kevlar Spammer last edited by

                [quote name=“delimitri” post=“48548” timestamp=“1388449163”]
                [quote author=Kevlar link=topic=6453.msg48454#msg48454 date=1388430164]
                And ZD WINS!!! Congrats. Very well done.

                One might call this a Monte-Carlo sort. It uses evolution to arrive at a perfectly sorted list by following this algorithm:

                1. Get a list of numbers.
                2. Randomly reorder the numbers in the list.
                3. See if this list is “more” sorted than the last one.
                4. If it’s perfectly sorted, we’re done.
                5. If it’s better, use it as the new list, and go to step 2.
                6. If it’s worse, throw it out and go back to step 2.

                This is, obviously, highly inefficient and a huge waste of time and code to accomplish something that could be done using a lot less work.

                The correct code to do this, as ZD correctly pointed out is with the one line of code: Collections.sort(list)

                FTC will be sent tonight. Stay tuned for the next Drunken Coding Challenge!
                [/quote]

                I might be blind, but it looks like ZD went to sleep.
                Wasn’t that my answer that mentioned Collections.sort(listName)? :o
                [/quote]

                Holy crap, I credited the wrong person entirely!!!

                I take it all back.

                delimitri wins!!! MY BAD!!! LOL. Sorry, please forgive me. I guess that’s what you get for running a drunken contest?

                Sorry about that! Funds will still be sent tonight! :)

                1 Reply Last reply Reply Quote 0
                • D
                  delimitri last edited by

                  [quote name=“Kevlar” post=“48454” timestamp=“1388430164”]

                  Holy crap, I credited the wrong person entirely!!!

                  I take it all back.

                  delimitri wins!!! MY BAD!!! LOL. Sorry, please forgive me. I guess that’s what you get for running a drunken contest?

                  Sorry about that! Funds will still be sent tonight! :)
                  [/quote]

                  Hahaha no problem. :D

                  I was just curious and looking for the answer in previous posts. I thought I might have missed it when reading through the responses the first time, and then when I couldn’t see anything I thought wait a minute… that was me… yay!!!

                  Thanks. Really appreciate it. I have only recently started mining, so only have 6 or 7 FTC at the moment. So this is a big bonus for me ;D

                  1 Reply Last reply Reply Quote 0
                  • T
                    Tuck Fheman last edited by

                    [quote name=“delimitri” post=“48548” timestamp=“1388449163”]
                    I might be blind, but it looks like ZD went to sleep.
                    [/quote]

                    I was closer than zd. ;)

                    1 Reply Last reply Reply Quote 0
                    • C
                      chrisj Regular Member last edited by

                      [quote name=“delimitri” post=“48557” timestamp=“1388450964”]
                      [quote author=Kevlar link=topic=6453.msg48454#msg48454 date=1388430164]

                      Holy crap, I credited the wrong person entirely!!!

                      I take it all back.

                      delimitri wins!!! MY BAD!!! LOL. Sorry, please forgive me. I guess that’s what you get for running a drunken contest?

                      Sorry about that! Funds will still be sent tonight! :)
                      [/quote]

                      Hahaha no problem. :D

                      I was just curious and looking for the answer in previous posts. I thought I might have missed it when reading through the responses the first time, and then when I couldn’t see anything I thought wait a minute… that was me… yay!!!

                      Thanks. Really appreciate it. I have only recently started mining, so only have 6 or 7 FTC at the moment. So this is a big bonus for me ;D
                      [/quote]

                      Congratulations delimitri. Welcome to the forum.

                      Great thread too, more like this please.

                      1 Reply Last reply Reply Quote 0
                      • K
                        Kevlar Spammer last edited by

                        [quote name=“delimitri” post=“48557” timestamp=“1388450964”]
                        [quote author=Kevlar link=topic=6453.msg48454#msg48454 date=1388430164]

                        Holy crap, I credited the wrong person entirely!!!

                        I take it all back.

                        delimitri wins!!! MY BAD!!! LOL. Sorry, please forgive me. I guess that’s what you get for running a drunken contest?

                        Sorry about that! Funds will still be sent tonight! :)
                        [/quote]

                        Hahaha no problem. :D

                        I was just curious and looking for the answer in previous posts. I thought I might have missed it when reading through the responses the first time, and then when I couldn’t see anything I thought wait a minute… that was me… yay!!!

                        Thanks. Really appreciate it. I have only recently started mining, so only have 6 or 7 FTC at the moment. So this is a big bonus for me ;D
                        [/quote]

                        I’m so embaressed by this. delimitri, you are definately the winner and I can’t believe I made such a silly mistake. Yeish! I hope your prize will make up for the confusion I must have caused you, and that you’ll participate in the next Drunken Coding Contest… which will be VERY soon!

                        Here’s your FTC: a5e98bb4c6ebc8f5210c8bfb2d5c6bb640fe198a3a17af26cfd80c96ef4df7d5

                        You can put that into the block explorer, and see that I just send 10 FTC to your signature address (ain’t transparency cool?).

                        Thanks again for participating, and hope to see you at the next one!

                        1 Reply Last reply Reply Quote 0
                        • D
                          delimitri last edited by

                          Thanks again for the FTC :)

                          Will definitely keep an eye out for the next challenge.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post