This commit is contained in:
DavidOnTop 2025-04-16 08:43:11 +02:00
parent ae70fd2920
commit 44c0c9ad68
Signed by: DavidOnTop
GPG key ID: 8D3E9A75E3E13D89
5 changed files with 83 additions and 5 deletions

26
src/u43.py Normal file
View file

@ -0,0 +1,26 @@
import turtle
t = turtle.Turtle()
def main():
t.penup()
t.setheading(0)
for i in range(0, 30):
next(i)
input()
def next(i):
t.goto(30 * i, 0)
color = ""
if i % 3 == 1:
color = "yellow"
elif i % 3 == 2:
color = "red"
elif i % 6 == 0:
color = "black"
elif i % 6 == 3:
color = "blue"
t.dot(30, color)
if __name__ == "__main__":
main()

View file

@ -1 +1,15 @@
pub fn main() {} use std::ffi::CString;
use pyo3::ffi::c_str;
use pyo3::prelude::{PyAnyMethods, PyModule};
use pyo3::Python;
static code: &'static str = include_str!("u43.py");
pub fn main() {
Python::with_gil(|py| {
let c = CString::new(code.as_bytes()).unwrap();
let activator =
PyModule::from_code(py, c.as_c_str(), c_str!("main.py"), c_str!("main")).unwrap();
activator.call_method("main", (), None).unwrap();
})
}

26
src/u45.py Normal file
View file

@ -0,0 +1,26 @@
import turtle
t = turtle.Turtle()
def main():
print()
side = int(input("strana? "))
n = int(input("kolko uholnik? "))
x = int(input("kolko opakovani? "))
angle = 360/x
for i in range(0, x):
t.setheading(i * angle)
nuholnik(n, side)
input()
def nuholnik(n: int, side: int):
angle = 360 / n
for i in range(0, n):
t.forward(side)
t.right(angle)
if __name__ == "__main__":
main()

View file

@ -1 +1,15 @@
pub fn main() {} use std::ffi::CString;
use pyo3::ffi::c_str;
use pyo3::prelude::{PyAnyMethods, PyModule};
use pyo3::Python;
static code: &'static str = include_str!("u45.py");
pub fn main() {
Python::with_gil(|py| {
let c = CString::new(code.as_bytes()).unwrap();
let activator =
PyModule::from_code(py, c.as_c_str(), c_str!("main.py"), c_str!("main")).unwrap();
activator.call_method("main", (), None).unwrap();
})
}

View file

@ -3,9 +3,7 @@ pub fn main() {
} }
fn rec(num: i32) { fn rec(num: i32) {
if num >= 1000 { if num >= 1000 { return };
return;
}
println!("num: {num}"); println!("num: {num}");
rec(num + 7) rec(num + 7)
} }