All interactions with the Exercism website are handled automatically. Representers have the single responsibility of taking a solution and returning a representation of it. See the introduction for more information.
two-fer
).representation.txt
file to the output directory.representation.json
file to the output directory.mapping.json
file to the output directory.The representer gets 100% machine resources for a 20 second window per solution. After 20 seconds, the process is halted and reports a time-out.
The representation.txt
file contains some sort of canonical representation. This representation can take many forms, but is usually an 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))))
The representation could also just be (normalized) source code:
class PLACEHOLDER_1
def PLACEHOLDER_2
PLACEHOLDER_3 = "foo"
PLACEHOLDER_4 = "foo"
return PLACEHOLDER_3
end
def PLACEHOLDER_3
PLACEHOLDER_1
end
end
The mapping.json
file maps placeholders to their original values:
{
"PLACEHOLDER_1": "TwoFer",
"PLACEHOLDER_2": "two_fer",
"PLACEHOLDER_3": "foo",
"PLACEHOLDER_4": "bar"
}
It is important to note that all identical names must be replaced with the same placeholder, irrespective of scope.
The representation.json
file contains metadata:
version
: the version number of the representer (defaults to 1
)Example:
{ "version": 2 }