Best way to randomize a text list???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OzMan
    Confirmed User
    • Sep 2003
    • 9162

    #1

    Best way to randomize a text list???

    I have a text file of the form:

    word1
    word2
    word3
    word4
    word5
    etc

    and I want something that will randomly change the order, for example:

    word3
    word1
    word5
    word2
    word4

    Any suggestions?
    Last edited by OzMan; 03-18-2005, 09:56 PM.
  • smack
    Push Porn Like Weight.
    • Mar 2002
    • 10652

    #2
    what language do you want to use?

    in VB i would just have a randomize statement run from the lbound to the ubound of the array and write them to a different file.
    Cry havoc and let slip the dogs of war.

    Comment

    • newbreed
      Confirmed User
      • Nov 2003
      • 9898

      #3
      <?php

      randomize OzMan's text!

      ?php>



















      j/k, I have no idea, but if that works, cheers man!

      Loryn ‎(3:16 PM):
      I love it, just as long as we keep the bedroom door closed from all ears then we can have throw down hard core sex that makes us money haha
      fuck it we can have sex on money never did that before

      Comment

      • OzMan
        Confirmed User
        • Sep 2003
        • 9162

        #4
        I just want a simple desktop app like textpad or something.

        There are a bunch that will sort a file .. alpha numeric ascending descending etc but I wanna do the opposite I guess

        Comment

        • Crypt
          Confirmed User
          • Apr 2004
          • 2225

          #5
          Originally posted by OzMan
          I just want a simple desktop app like textpad or something.

          There are a bunch that will sort a file .. alpha numeric ascending descending etc but I wanna do the opposite I guess
          ListMate ;)

          Comment

          • OzMan
            Confirmed User
            • Sep 2003
            • 9162

            #6
            Originally posted by Crypt
            ListMate ;)
            checking that out , Thanks

            anyone else?

            Comment

            • 2HousePlague
              CURATOR
              • Jul 2004
              • 14572

              #7
              Is this for ENCRYPTION purposes?

              If so, try this...


              j-
              tada!

              Comment

              • Explicit
                Confirmed User
                • Jul 2004
                • 814

                #8
                simple code, and im not a programmer. assign em each a variable, randomize the lot, order from least to greatest.. or somethin

                Comment

                • xl11
                  Confirmed User
                  • Jul 2003
                  • 712

                  #9
                  PHP Code:
                  
                  <?
                  
                  $data = file('data.txt');
                  
                  shuffle($data);
                  
                  foreach ($data as $value) {
                  
                     echo "Value: $value<br />\n";
                  
                  }
                  ?>

                  Comment

                  • The Sultan Of Smut
                    Confirmed User
                    • Dec 2004
                    • 4325

                    #10
                    You can use Excel and put your text in column A and then use the rand function in column B then sort.

                    Comment

                    • Dirty F
                      Too lazy to set a custom title
                      • Jul 2001
                      • 59204

                      #11
                      elistpro ;)

                      Comment

                      • Explicit
                        Confirmed User
                        • Jul 2004
                        • 814

                        #12
                        Originally posted by xl11
                        PHP Code:
                        
                        <?
                        
                        $data = file('data.txt');
                        
                        shuffle($data);
                        
                        foreach ($data as $value) {
                        
                           echo "Value: $value<br />\n";
                        
                        }
                        ?>
                        wow, i was pretty damn close ehh, thanks for the visual.

                        Comment

                        • bbe
                          Confirmed User
                          • Feb 2005
                          • 110

                          #13
                          #!/usr/bin/perl

                          # Read File
                          while (<>) {
                          push(foo, $_);
                          }

                          # Shuffle lines
                          srand;
                          for (0..$#foo) {
                          $r = rand($#foo+1);
                          ($foo[$r], $foo[$_]) = ($foo[$_], $foo[$r]);
                          }

                          # Print it out
                          for (0..$#foo) {
                          print $foo[$_];
                          }

                          Comment

                          • fris
                            I have to go potty
                            • Aug 2002
                            • 55800

                            #14
                            $filename = "ban.txt";
                            $sites = file($filename);
                            srand ((double) microtime() * 1000000);
                            $a = rand(0, sizeof($sites) - 1);
                            echo $sites[$a];
                            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                            My Newest Theme

                            Comment

                            • fris
                              I have to go potty
                              • Aug 2002
                              • 55800

                              #15
                              in ban.txt put a list on each line
                              Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                              My Newest Theme

                              Comment

                              • OzMan
                                Confirmed User
                                • Sep 2003
                                • 9162

                                #16
                                Interesting ideas here Thanks for the info

                                Comment

                                • KRosh
                                  So Fucking Outlawed
                                  • Nov 2001
                                  • 5114

                                  #17
                                  elistpro


                                  or textpad I think does it .. and it's free
                                  ICQ 115433750

                                  Comment

                                  • WebTitan
                                    Confirmed User
                                    • Mar 2003
                                    • 5114

                                    #18
                                    Originally posted by The Sultan Of Smut
                                    You can use Excel and put your text in column A and then use the rand function in column B then sort.
                                    was going to be my suggestion

                                    Comment

                                    Working...