def cerc_triunghi():
R = 6
C.setXminXmaxYminYmax(-10, 10, -10, 10)
C.fillScreen(Color.Whitesmoke)
A = complex(-6, 0)
B = complex(6, 0)
D = complex(0, 6)
centru = complex(0, 0)
raza = R
for z in C.screenAffixes():
x, y = z.real, z.imag
in_cerc = abs(z - centru) <= raza
cond1 = (y - A.imag) * (B.real - A.real) - (x - A.real) * (B.imag - A.imag) > 0
cond2 = (y - B.imag) * (D.real - B.real) - (x - B.real) * (D.imag - B.imag) > 0
cond3 = (y - D.imag) * (A.real - D.real) - (x - D.real) * (A.imag - D.imag) > 0
cond4 = (y - A.imag) * (B.real - A.real) - (x - A.real) * (B.imag - A.imag) < 0
cond5 = (y - B.imag) * (D.real - B.real) - (x - B.real) * (D.imag - B.imag) < 0
cond6 = (y - D.imag) * (A.real - D.real) - (x - D.real) * (A.imag - D.imag) < 0
in_triunghi = cond1 and cond2 and cond3
if in_triunghi:
col = Color.Yellow
elif in_cerc and cond4:
col = Color.Cyan
elif in_cerc and cond5:
col = Color.Magenta
elif in_cerc and cond6:
col = Color.Blueviolet
elif not in_cerc and cond4 and cond2 and cond3:
col = Color.Green
elif not in_cerc and cond5 and cond1 and cond3:
col = Color.Darkolivegreen
elif not in_cerc and cond6 and cond1 and cond2:
col = Color.Firebrick
elif not in_cerc and cond1 and cond5 and cond6:
col = Color.Orange
elif not in_cerc and cond2 and cond4 and cond6:
col = Color.Pink
elif not in_cerc and cond3 and cond4 and cond5:
col = Color.Ghostwhite
C.setPixel(z, col)
ZGVmIGNlcmNfdHJpdW5naGkoKToKICAgIFIgPSA2CiAgICBDLnNldFhtaW5YbWF4WW1pblltYXgoLTEwLCAxMCwgLTEwLCAxMCkKICAgIEMuZmlsbFNjcmVlbihDb2xvci5XaGl0ZXNtb2tlKQoKCiAgICBBID0gY29tcGxleCgtNiwgMCkKICAgIEIgPSBjb21wbGV4KDYsIDApCiAgICBEID0gY29tcGxleCgwLCA2KQoKCiAgICBjZW50cnUgPSBjb21wbGV4KDAsI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YW5kIGNvbmQ1OgogICAgICAgICAgICBjb2wgPSBDb2xvci5NYWdlbnRhCiAgICAgICAgZWxpZiBpbl9jZXJjIGFuZCBjb25kNjoKICAgICAgICAgICAgY29sID0gQ29sb3IuQmx1ZXZpb2xldAogICAgICAgIGVsaWYgbm90IGluX2NlcmMgYW5kIGNvbmQ0IGFuZCBjb25kMiBhbmQgY29uZDM6CiAgICAgICAgICAgIGNvbCA9IENvbG9yLkdyZWVuCiAgICAgICAgZWxpZiBub3QgaW5fY2VyYyBhbmQgY29uZDUgYW5kIGNvbmQxIGFuZCBjb25kMzoKICAgICAgICAgICAgY29sID0gQ29sb3IuRGFya29saXZlZ3JlZW4KICAgICAgICBlbGlmIG5vdCBpbl9jZXJjIGFuZCBjb25kNiBhbmQgY29uZDEgYW5kIGNvbmQyOgogICAgICAgICAgICBjb2wgPSBDb2xvci5GaXJlYnJpY2sKICAgICAgICBlbGlmIG5vdCBpbl9jZXJjIGFuZCBjb25kMSBhbmQgY29uZDUgYW5kIGNvbmQ2OgogICAgICAgICAgICBjb2wgPSBDb2xvci5PcmFuZ2UKICAgICAgICBlbGlmIG5vdCBpbl9jZXJjIGFuZCBjb25kMiBhbmQgY29uZDQgYW5kIGNvbmQ2OgogICAgICAgICAgICBjb2wgPSBDb2xvci5QaW5rCiAgICAgICAgZWxpZiBub3QgaW5fY2VyYyBhbmQgY29uZDMgYW5kIGNvbmQ0IGFuZCBjb25kNToKICAgICAgICAgICAgY29sID0gQ29sb3IuR2hvc3R3aGl0ZQoKICAgICAgICBDLnNldFBpeGVsKHosIGNvbCk=