Work with specifications partly added

This commit is contained in:
anwinged
2012-04-23 07:02:06 +00:00
parent 42d7aa9573
commit d859399249
6 changed files with 212 additions and 40 deletions

View File

@ -1,13 +1,13 @@
{
"title": "Example task",
"author": "Anton Vakhrushev",
"meta": "av-example-task",
"meta": "av-example-task-version-00-10",
"models": {
"sintaylor": {
"title": "Simple model for example",
"title": "Simple model",
"author": "Anton Vakhrushev",
"date": "2012-03-08",
@ -31,10 +31,25 @@
"n": {
"type": "int",
"default": 10,
"default": 100,
"title": "Steps",
"comment": "Number of steps for algorithm"
}
},
"spec": {
"left": {
"title": "Left"
},
"right": {
"title": "Right"
},
"trapezium": {
"title": "Trapezium"
}
}
}
}

View File

@ -26,10 +26,11 @@ def sin_taylor(x, n):
e *= -1
return s
def answer(p):
def answer(p, c = ''):
return json.dumps({
"answer": "ok",
"value": p
"value": p,
"comment": c
})
def error(msg):
@ -61,7 +62,7 @@ def main():
textdata = raw_input()
data = json.loads(textdata)
if not len(data) and data[0]['label'] != 'sintaylor':
if not len(data) or data[-1]['label'] != 'sintaylor':
write(error('Unknown model'))
sys.exit(1)
@ -76,9 +77,9 @@ def main():
while l <= r:
y = sin_taylor(l, d)
res.append([l, y])
write(answer(l / r))
write(answer(l / r, data[-1]['label']))
l += h
#time.sleep(0.1)
time.sleep(0.1)
write(result(res))