「モジュール:テスト2」の版間の差分

提供:WikiWiki
ナビゲーションに移動 検索に移動
編集の要約なし
(内容を「local p={} return p」で置換)
タグ: 置換
 
(同じ利用者による、間の5版が非表示)
1行目: 1行目:
local p={}
local p={}
function p.listTurples(frame)
local ansTyp = frame.args[1]
local ans = assert(tonumber(frame.args[2]), "答えを半角数字で指定してください。")
local arr = {}
local t = 3
while frame.args[t] do
arr[t-2] = frame.args[t]
t = t + 1
end
return table.concat(arr)
--[[local output = ""
if ansTyp == "sum"then
for i = 1, #arr - 2 do
for j = i + 1, #arr - 1 do
if i ~= j then
local rest = ans - i - j
for k = j + 1, #arr do
if arr[k] == rest then
output = output.."("..arr[i]..","..arr[j]..","..rest..")"
end
end
end
end
end
if output == "" then return "指定された条件に適する組はありません。" end
return output
elseif ansTyp == "product" then
for i = 1, #arr - 2 do
for j = i + 1, #arr - 1 do
if i ~= j then
if ans % (i * j) == 0 then
rest = ans % (i * j)
for k = j + 1, #arr do
if arr[k] == rest then
output = output.."("..arr[i]..","..arr[j]..","..rest..")"
end
end
end
end
end
end
if output == "" then return "指定された条件に適する組はありません。" end
return output
else
error("答えの種類を適切に指定してください")
end
]]
end


return p
return p

2年12月9日 (K) 11:13時点における最新版

このモジュールについての説明文ページを モジュール:テスト2/doc に作成できます

local p={}

return p