|
|
| (2人の利用者による、間の31版が非表示) |
| 1行目: |
1行目: |
| local p = {}
| | --[[category:唯一の編集者により削除が依頼されているページ]] |
| | |
| function p.main(frame)
| |
| local args = frame.args
| |
| local team = {}
| |
| local nRow = { [0] = {} }
| |
| local line = {}
| |
|
| |
| local i = 1
| |
| while args[i] ~= "result" do
| |
| team[i] = args[i]
| |
| nRow[0][i] = 1
| |
| i = i + 1
| |
| end
| |
| local nTeam = i - 1
| |
| i = i + 1
| |
|
| |
| local round = 1
| |
| local curr = 1
| |
| local prev = 1
| |
| local row = 0
| |
| nRow[1] = {}
| |
| while args[i] ~= nil do
| |
| if args[i] == "bye" then
| |
| nRow[round][curr] = nRow[round-1][prev]
| |
| nRow[round][curr+1] = nRow[round-1][prev+1]
| |
| prev = prev + 2
| |
| i = i + 1
| |
| else
| |
| if nRow[round-1][prev+2] == nil then break end
| |
| local prev1 = nRow[round-1][prev+1]
| |
| local prev2 = nRow[round-1][prev+2]
| |
| local curr1
| |
| if prev1 > prev2 then
| |
| curr1 = (prev1 + prev2 + (curr1 % 2)) / 2
| |
| else
| |
| curr1 = (prev1 + prev2 - (curr1 % 2)) / 2
| |
| end
| |
| local curr2 = (prev1 + prev2) - curr1
| |
| nRow[round][curr] = nRow[round-1][prev] + curr1
| |
| nRow[round][curr+1] = nRow[round-1][prev+3] + curr2
| |
| prev = prev + 4
| |
| i = i + 4
| |
| end
| |
| row = row + nRow[round][curr] + nRow[round][curr+1]
| |
| if row == nTeam then
| |
| round = round + 1
| |
| curr = 1
| |
| prev = 1
| |
| row = 0
| |
| nRow[round] = {}
| |
| else
| |
| curr = curr + 2
| |
| end
| |
| end
| |
| | |
| return ""
| |
| end
| |
| | |
| return p
| |