|
|
(2人の利用者による、間の30版が非表示) |
行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]
| + | |
− | data[0][i] = {a = 1, b = 1}
| + | |
− | i = i + 1
| + | |
− | end
| + | |
− | local nTeam = i - 1
| + | |
− | i = i + 1
| + | |
− |
| + | |
− | local round = 1
| + | |
− | local curr = 1
| + | |
− | local prev = 1
| + | |
− | local row = 0
| + | |
− | data[1] = {}
| + | |
− | while args[i] ~= nil and row == 0 do
| + | |
− | data[round][curr] = {}
| + | |
− | data[round][curr].e = data[round-1][prev].e
| + | |
− | data[round][curr].f = data[round-1][prev].f
| + | |
− |
| + | |
− | if args[i] == "bye" then
| + | |
− | i = i + 1
| + | |
− | elseif data[round-1][prev+1] ~= nil then
| + | |
− | local prev1 = data[round-1][prev].e
| + | |
− | local prev2 = data[round-1][prev].f
| + | |
− | local prev3 = data[round-1][prev+1].e
| + | |
− | local prev4 = data[round-1][prev+1].f
| + | |
− | local curr1
| + | |
− | if prev2 > prev3 then
| + | |
− | curr1 = (prev2 + prev3 + (curr1 % 2)) / 2
| + | |
− | else
| + | |
− | curr1 = (prev2 + prev3 - (curr1 % 2)) / 2
| + | |
− | end
| + | |
− | local curr2 = (prev2 + prev3) - curr1
| + | |
− | data[round][curr] = {
| + | |
− | a = prev1, b = prev2, c = prev3, d = prev4, e = curr1, f = curr2,
| + | |
− | args[i], args[i+1], args[i+2], args[i+3]
| + | |
− | }
| + | |
− | i = i + 4
| + | |
− | end
| + | |
− |
| + | |
− | prev = prev + 1
| + | |
− | row = row + data[round][curr].e + data[round][curr].f
| + | |
− | if row == nTeam then
| + | |
− | round = round + 1
| + | |
− | curr = 1
| + | |
− | prev = 1
| + | |
− | row = 0
| + | |
− | data[round] = {}
| + | |
− | else
| + | |
− | curr = curr + 1
| + | |
− | end
| + | |
− | end
| + | |
− | round = round - 1
| + | |
− |
| + | |
− |
| + | |
− |
| + | |
− |
| + | |
− |
| + | |
− |
| + | |
− |
| + | |
− |
| + | |
− | return ""
| + | |
− | end
| + | |
− | | + | |
− | return p
| + | |