Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Tournament Help
Author Message
l0tt0

Posted: Thu Dec 04, 2003 10:56 pm   Post subject: Tournament Help

Hey Everyone, I made this tournament code for my site to find out who's where in the tournament. I haven't learned how to do tony's proc to check to make sure two numbers are the same so i just used the big exit when line. What i want to know is if there's anyway to amke it run faster besides a better system of making sure no matches are the same?

Thanks.

 code: var l: array 1..8 of int       % First Set Of Numbers  var r: array 1..8 of int       % Second Set Of Numbers  var n: array 1..16 of string   % Name Of People Competing In Tournament   for x: 1..16                    % Getting The Names of People In The Tournament     put "Please enter a name in the tournament(",x,")"     get n(x) end for     loop        cls     for z: 1..8         l(z):=Rand.Int(1,8)    % First Set Of Random Numbers         r(z):=Rand.Int(1,8)    % Second Set Of Random Numbers     end for     exit when l(1) not=l(2) and l(1) not=l(3) and l(1) not=l(4) and l(1) not=l(5) and l(1) not=l(6) and l(1) not=l(7) and l(1) not=l(8)      and  l(2) not=l(3) and l(2) not=l(4) and l(2) not=l(5) and l(2) not=l(6) and l(2) not=l(7) and l(2) not=l(8)      and  l(3) not=l(4) and l(3) not=l(5) and l(3) not=l(6) and l(3) not=l(7) and l(3) not=l(8)      and  l(4) not=l(5) and l(4) not=l(6) and l(4) not=l(7) and l(4) not=l(8)      and  l(5) not=l(6) and l(5) not=l(7) and l(5) not=l(8)      and  l(6) not=l(7) and l(6) not=l(8)      and  l(7) not=l(8)           and  r(1) not=r(2) and r(1) not=r(3) and r(1) not=r(4) and r(1) not=r(5) and r(1) not=r(6) and r(1) not=r(7) and r(1) not=r(8)      and  r(2) not=r(3) and r(2) not=r(4) and r(2) not=r(5) and r(2) not=r(6) and r(2) not=r(7) and r(2) not=r(8)      and  r(3) not=r(4) and r(3) not=r(5) and r(3) not=r(6) and r(3) not=r(7) and r(3) not=r(8)      and  r(4) not=r(5) and r(4) not=r(6) and r(4) not=r(7) and r(4) not=r(8)      and  r(5) not=r(6) and r(5) not=r(7) and r(5) not=r(8)      and  r(6) not=r(7) and r(6) not=r(8)      and  r(7) not=r(8)      end loop for a: 1..8     put n(a),"-",l(a)         % Displays First 1-8 Names With Number end for for b: 1..8     put n(b+8),"-",r(b)       % Displays Second Set of Names With Number end for

Tony

Posted: Thu Dec 04, 2003 11:53 pm   Post subject: (No subject)

wow man... could you do yourself a favor and take Data Managment in grade 12?

When generating 8 random numbers (from 1 to 8), what are the chances of them to generate an unique list?

well chances of first to not repeat are 1/1
second - 7/8
third - 6/8
...
eighth - 1/8...

multiply all those numbers together... you get 0.0025

they translate into 1:400 odds of you generating a unique list
Tony's programming blog. DWITE - a programming contest.
l0tt0

Posted: Sun Dec 07, 2003 11:59 pm   Post subject: (No subject)

huh?

im only in grade 10...but i think i understand what u said...almost

taht there's practically no chance of gettin those numbers...?

Posted: Mon Dec 08, 2003 12:06 am   Post subject: ..

ok....is this code s upposed to go through long random pointless (algorithyms) to find 1 person from each list to go against each other in a tournament? If so, its so much easier that that.
 code: var tournlist_1,tournlist_2:array 1..20 of int var tourn_num1,tourn_num2:int:=1 randint(tourn_num1,1,20) randint(tourn_num2,1,20) put tournlist_1(tourn_num1) put "faces off against" put tournlist_2(tourn_num2)

Just ask for the names of the tournament people under the variables.
Hopefully I understood what your program was doing. (Maybe make a couple comments?)
AsianSensation

Posted: Mon Dec 08, 2003 12:09 am   Post subject: (No subject)

but with your code, a person could go against him or herself.

Also, in a tournament, I think you only play each person once. Or something like that, so a bit of math is involved. just use the stuff you learned in data management.
Tony

Posted: Mon Dec 08, 2003 10:09 am   Post subject: (No subject)

the guy is not in data managment, he's in grade 10

anyways, here's the link to the source code for that random list generator. Try to understand how it works.
Tony's programming blog. DWITE - a programming contest.

Posted: Mon Dec 08, 2003 12:05 pm   Post subject: ..

Ok, just make a new array...like for people who already played. Like.....
 code: var tournie_used_people:array 1..40 of int %Do the script that makes a random name, and check if its not fighting itself... %Then check this array to see if names have been picked, if they have, redo randint
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 7 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: