與 Exercism 網站的所有互動都會自動處理。 Representer 的單一職責是取得 solution 並回傳它的 representation。 詳情請參閱簡介。
two-fer)。representation.txt 檔案寫入輸出目錄。representation.json 檔案寫入輸出目錄。mapping.json 檔案寫入輸出目錄。針對每個 solution,representer 可獲得 20 秒的 100% 機器資源。 超過 20 秒後,行程會遭到中止並回報逾時。
我們強烈建議遵循我們的效能最佳實務文件,以降低逾時的機會。
representation.txt 檔案包含某種標準化的 representation。representation 可以有許多形式,但通常是 AST:
s(:class,
s(:const, nil, :PLACEHOLDER_1), nil,
s(:begin,
s(:def, :PLACEHOLDER_2,
s(:args),
s(:begin,
s(:lvasgn, :PLACEHOLDER_3,
s(:str, "foo")),
s(:lvasgn, :PLACEHOLDER_4,
s(:str, "foo")),
s(:return,
s(:lvar, :PLACEHOLDER_3)))),
s(:def, :PLACEHOLDER_3,
s(:args),
s(:const, nil, :PLACEHOLDER_1))))
representation 也可以就只是(正規化後的)原始碼:
class PLACEHOLDER_1
def PLACEHOLDER_2
PLACEHOLDER_3 = "foo"
PLACEHOLDER_4 = "foo"
return PLACEHOLDER_3
end
def PLACEHOLDER_3
PLACEHOLDER_1
end
end
mapping.json 檔案會將預留位置對應到它們的原始值:
{
"PLACEHOLDER_1": "TwoFer",
"PLACEHOLDER_2": "two_fer",
"PLACEHOLDER_3": "foo",
"PLACEHOLDER_4": "bar"
}
請注意,所有相同的名稱都必須替換成同一個預留位置,無論其作用域為何。
representation.json 檔案包含中繼資料:
version:representer 的版本號(預設為 1)範例:
{ "version": 2 }