Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-21-2008, 09:22 AM
Whitey's Avatar   
Whitey Whitey is offline
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 225
Rep Power: 6
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default Tournament Generate

Okay i am trying to make this generate for 4 8 and 16 size tournaments.
Here is my example
http://clansi.net/test2.php

but as you can see that would take alot of space and the runtime slow.
I also want to learn to generate it for learning purpose's

Also i can see a math equation in it
Round 1 starts at box 1 (having 0 being the round name) then goes adding 2 after that for each name
Round 2 has 2 Space at the start (The spaces consecutive in round 1) and adds 4 consecutive.. (it doubles) the math equation is used throught the whole pattern

Given Start 1
Take the number before double it (2)
then use 2 and take that number and double it (4)
hard to explain but this is just babling haha just if you can help me generate that tournment by actually inputting any number that would be great
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-21-2008, 01:56 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Tournament Generate

The first thing I would do is work out a relationship between the number of teams playing and the number of rounds played.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-21-2008, 04:20 PM
Whitey's Avatar   
Whitey Whitey is offline
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 225
Rep Power: 6
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default Re: Tournament Generate

Well if i do it by 4 - 8 - 16 it would be 3 - 4 - 5
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-21-2008, 08:36 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Tournament Generate

How about if you did it by "n" - any arbitrary number? Then what would it be (in terms of n).
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-27-2008, 04:32 PM
Whitey's Avatar   
Whitey Whitey is offline
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 225
Rep Power: 6
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default Re: Tournament Generate

Thats really hard to make i am confusing myself when trying to make it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 08-27-2008, 04:42 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,271
Last Blog:
wxWidgets is NOT code ...
Rep Power: 36
WingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to all
Default Re: Tournament Generate

Try looking at it like this:
Code:
Teams : Rounds
1     : 0
2     : 1
3-4   : 2
5-8   : 3
9-16  : 4
17-32 : 5
In particular, notice that the high values are powers of two
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Programming is a branch of mathematics.

Last edited by WingedPanther; 08-27-2008 at 04:44 PM. Reason: formatting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-28-2008, 06:58 AM
orjan's Avatar   
orjan orjan is offline
Programming Professional
 
Join Date: Sep 2007
Location: Sunne, Värmland, Sweden
Age: 33
Posts: 328
Last Blog:
Procedural Programming...
Rep Power: 9
orjan has a spectacular aura aboutorjan has a spectacular aura aboutorjan has a spectacular aura about
Default Re: Tournament Generate

number of rounds is the same as the highest bit has in the byte-value that has a 1

ex:
11 = 00001011; 4th bit is set with means we will have 4 rounds
23 = 00010111; 5th bit is set -> 5 rounds

then it's "just" to write a nice procedure to calculate this...

PHP Code:
    function highbit($a) {
        
$highbit 0;
        
$bitcomp 1;
        for (
$i=1$i<16$i++) {
            if (
$a $bitcomp) {
                
$highbit $i;
            }
            
$bitcomp $bitcomp << 1;
        }
        return 
$highbit;
    } 
this function works for up to 16384 players, if more needed, just change the value in the for-loop, from 16 to a higher value. Just put number of players as parameter to the function. highbit(57) would give 6 (max 64) and highbit(23) would give 5 (max 32)

Last edited by orjan; 08-28-2008 at 07:42 AM. Reason: Added an function
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate text with transparent background AfTriX PHP Tutorials 1 01-08-2007 03:13 AM
Generate random points tim838 Java Help 2 10-16-2006 07:59 PM
I need to generate a random number in PHP dirkfirst PHP Forum 7 07-05-2006 10:58 PM


All times are GMT -5. The time now is 05:33 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads