Grand National Sweepstake

Log in to stop seeing adverts

Status
Not open for further replies.
Shock News: Big Edna IS dead
 
Dead lucky to have you as a customer every week, tucking into her apple dumplings

"Vinegar Tits" Vera is still there, as well - keep away from her frosted cupcakes, though. Not nice
 
homer said:
Dead lucky to have you as a customer every week, tucking into her apple dumplings

"Vinegar Tits" Vera is still there, as well - keep away from her frosted cupcakes, though. Not nice

I'll take your word for it.
I actually spend most of my time with Eggy Edith but sometimes her farts are unbearable. Some disgusting fanny farts come out of her - but you already now that don't you homer. :eek:
 
Steven said:
I could write a Java Class to generate two random lists each 40 long, one containing the number chosen by a TBer and one corresponding to the number of the horse.

Then just take top of each list and that is the pairing and so on down the list.

I would even publish the code so there is no cheating. :wink: ;-) :mrgreen:

Code:
/*
 * Created on 08-Apr-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package test;

import java.util.*;

/**
 * @author Steven 
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Draw {
    
    private void generateLists(int horses, int persons) {
        
        Random r = new Random((Calendar.getInstance()).getTimeInMillis());
        Random r1 = new Random();
        Stack horsesS = new Stack();
        Stack personsS = new Stack();
        Hashtable h = new Hashtable();
        Hashtable p = new Hashtable();
        int loopCounter = 0;
        
        
        // assume horse <= persons
        while (loopCounter < horses) {
            
            boolean numberGenerated = false;
            // first the horses list
            while (!numberGenerated) {
                int i = r.nextInt(horses + 1);
                if (i != 0) {
                    String s = Integer.toString(i);
                    boolean b = h.containsKey(s);
                    if (b) {                
                        numberGenerated = false;
                    } else {
                        horsesS.push(s);
                        h.put(s, new Integer(i));
                        numberGenerated = true;
                        loopCounter++; 
                    }
                } else {
                    numberGenerated = false;  
                }
            }
            numberGenerated = false;
            // then the persons list
            while (!numberGenerated) {
                int i = r1.nextInt(persons + 1);
                if (i != 0) {
                    String s = Integer.toString(i);
                    boolean b = p.containsKey(s);
                    if (b) {                
                        numberGenerated = false;
                    } else {
                        personsS.push(s);
                        p.put(s, new Integer(i));
                        numberGenerated = true;
                    }
                } else {
                    numberGenerated = false;
                }
            }
            
        }
        
        System.out.println("The List is as follows :\n");
        while ( !horsesS.isEmpty()) {
            System.out.println("Horse number :- " + " " + horsesS.pop() + 
                    " Person number :- " + " " + personsS.pop() );
        }

        
        
    }

    public static void main(String[] args) {
    
        int horses = 0;
        int persons = 0;
        
        try {
            horses = Integer.parseInt(args[0]);
            persons = Integer.parseInt(args[1]);
        } catch (Exception e) {
            System.out.println("We have an invalid number");
        }
        
        Draw d = new Draw();
        d.generateLists(horses, persons);
        
    }
}




Code:
The List is as follows :

Horse number :-  4 Person number :-  2
Horse number :-  10 Person number :-  25
Horse number :-  5 Person number :-  33
Horse number :-  35 Person number :-  18
Horse number :-  27 Person number :-  24
Horse number :-  40 Person number :-  22
Horse number :-  26 Person number :-  37
Horse number :-  34 Person number :-  36
Horse number :-  16 Person number :-  20
Horse number :-  37 Person number :-  38
Horse number :-  30 Person number :-  13
Horse number :-  1 Person number :-  26
Horse number :-  25 Person number :-  16
Horse number :-  18 Person number :-  3
Horse number :-  22 Person number :-  4
Horse number :-  13 Person number :-  19
Horse number :-  20 Person number :-  15
Horse number :-  39 Person number :-  7
Horse number :-  12 Person number :-  14
Horse number :-  24 Person number :-  1
Horse number :-  33 Person number :-  8
Horse number :-  29 Person number :-  11
Horse number :-  19 Person number :-  9
Horse number :-  36 Person number :-  17
Horse number :-  23 Person number :-  10
Horse number :-  2 Person number :-  12
Horse number :-  9 Person number :-  39
Horse number :-  6 Person number :-  5
Horse number :-  8 Person number :-  21
Horse number :-  11 Person number :-  29
Horse number :-  31 Person number :-  6
Horse number :-  15 Person number :-  40
Horse number :-  21 Person number :-  32
Horse number :-  38 Person number :-  27
Horse number :-  7 Person number :-  31
Horse number :-  14 Person number :-  28
Horse number :-  32 Person number :-  30
Horse number :-  3 Person number :-  34
Horse number :-  17 Person number :-  35
Horse number :-  28 Person number :-  23


:wink: ;-) :mrgreen:
 
Yeah but no one cares about that steven.
 
Status
Not open for further replies.
Log in to stop seeing adverts

P Pld Pts
1Liverpool1128
2Manchester C  1123
3Chelsea1119
4Arsenal1119
5Nottm F1119
6Brighton1119
7Fulham1118
8Newcastle1118
9Aston Villa1118
10Tottenham 1116
11Brentford1116
12Bournemouth1115
13Manchester U1115
14West Ham1112
15Leicester1110
16Everton1110
17Ipswich118
18Palace117
19Wolves116
20Southampton114

Latest posts

Back
Top