Coloured rays
Task
The canvas is 400 × 400. After every click draw a line (a ray) from the centre of the canvas (200, 200) to the click. The ray's colour depends on the quarter you clicked in: top left red, top right blue, bottom left green and bottom right orange.
The program runs in a tkinter simulation right in your browser - after Run you see the window and can click it. The tests click and check what was drawn on the canvas.
Examples
Call
from tkinter import _mente as okno kliky = [(100, 100, "red"), (300, 100, "blue"), (100, 300, "green"), (300, 300, "orange")] for x, y, farba in kliky: okno.click(x, y) ciary = okno.items("line") okno.check("styri kliky, styri luce", len(ciary) == 4, f"ciar: {len(ciary)}") for ciara, (x, y, farba) in zip(ciary, kliky): konce = {(round(ciara.coords[0]), round(ciara.coords[1])), (round(ciara.coords[-2]), round(ciara.coords[-1]))} okno.check(f"luc do ({x}, {y})", konce == {(200, 200), (x, y)} and okno.rgb(ciara.fill) == okno.rgb(farba), f"konce {sorted(konce)}, farba {ciara.fill}")Expected output
styri kliky, styri luce: OK luc do (100, 100): OK luc do (300, 100): OK luc do (100, 300): OK luc do (300, 300): OK
After you submit, 1 hidden test will also check your solution: clicks near the centre.
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.