-
Notifications
You must be signed in to change notification settings - Fork 2
Problem Definition
Matthew Merrill edited this page Apr 10, 2018
·
2 revisions
Each problem is defined by a textproto file in the problems subdirectory of the data directory. A minimal debugging problem definition looks like:
id: 1
title: "Echo"
description_text: "Python program to echo the first input line"
order_index: 1
color: '#ccaabb'
debugging_problem: {
language: "python3"
precode: "# Uses the print and input functions"
code: "print(input)"
postcode: ""
answer: "print(input())"
}
-
id: int32 uniquely identifying this problem -
title: string -
description: defined by including one of the following:-
description_text: inline HTML. -
description_file: path to an HTML file containing the description, resolved relative to the problems directory.
-
-
order_index: int32 used to sort problems in a specific order -
color: string hex used to accent. For competitions with balloons, this would ideally match the problem's balloon color.
-
value: defined by including one of the following:
-
debugging_problem: message containing debugging-specific data.-
language: string describing the programming language used. Only used for aesthetic purposes. -
precode: string of uneditable code before the editable section -
code: string of editable code -
postcode: string of uneditable code after the editable section -
answer: string of whatcodeshould look like after edits to be considered correct -
definition_file: string path to a code file. If this is set, then the chunks inside will overrideprecode/code/postcode/answeras shown below. Use line comments with no indentation to define a chunk. Line comments with indentation behavior is undefined.
-
// fizzbuzz.textproto
id: 2
title: "FizzBuzz"
description_file: "fizzbuzz.html"
order_index: 2
color: '#aaccbb'
debugging_problem: {
language: "python3"
definition_file: "fizzbuzz.dbg.py"
}
<!-- fizzbuzz.html -->
<span>
If multiple of 3, return "Fizz". If multiple of 5, "Buzz".
If 3 and 5, "FizzBuzz". Otherwise, return the original number.
</span>
<div class="descriptionIO">
<pre>
0
2
3
4
5
14
15
16
</pre>
<pre>
FizzBuzz
2
Fizz
4
Buzz
14
FizzBuzz
16
</pre>
</div>
# fizzbuzz.dbg.py
# @DBG:PRECODE
def fizzbuzz():
n = int(input())
mul3 = n % 3 == 0
mul5 = n % 5 == 0
# @DBG:CODE
if mul3:
return 'Fizz'
if mul5:
return 'Buzz'
if mul3 and mul5:
return 'FizzBuzz'
# @DBG:ANSWER
if mul3 and mul5:
return 'FizzBuzz'
if mul3:
return 'Fizz'
if mul5:
return 'Buzz'
# @DBG:POSTCODE
return str(n)