2011-02-06 44 views
5

如果你熟悉任何幻想體育草案,該草案階格看起來是這樣的:數學題(蛇)草案

EXAMPLE 1 (3-teams): 
Round Team 1 Team 2 Team 3 
    1  1 (1.1) 2 (1.2) 3 (1.3) 
    2  6 (2.3) 5 (2.2) 4 (2.1) 
    3  7 (3.1) 8 (3.2) 9 (3.3) 

數字1-9表示的overall pick number草案。

括號內的項代表round_numberpick_number_of_that_round

我找不出一個公式,它將我的overall_pick_number轉換成它合適的pick_number_of_that_round

在上面的例子中,數字8等於2(第三輪的第二個選擇)。但在四隊的聯賽中,8號等於4(第二輪第四順位)。

EXAMPLE 2 (4-teams): 
Round Team 1 Team 2 Team 3 Team 4 
    1  1 (1.1) 2 (1.2) 3 (1.3) 4 (1.4) 
    2  8 (2.4) 7 (2.3) 6 (2.2) 5 (2.1) 
    3  9 (3.1) 10 (3.2) 11 (3.3) 12 (3.4) 

我想過嘗試動態地構建基於球隊在聯賽中含有每挑挑哪個它屬於數量的關聯數組,但它只是超越我。

回答

5
round_number   = ((overall-1)/number_of_teams) + 1 
pick_number_of_round = ((overall-1) % number_of_teams) + 1 
+0

我不得不投了`round_number`到`(INT)`實現我想要的結果。非常感謝您花時間提供幫助。 – Jeff 2011-02-06 18:58:32

6

我會修改由missingno的答案,使之扭曲像「蛇」

round_number   = ((overall_pick_number - 1)/number_of_teams) + 1 
pick_number_of_round = ((overall_pick_number - 1) % number_of_teams) + 1 
if (round_number % 2 == 0) { 
    pick_number_of_round = number_of_teams - pick_number_of_round + 1 
}