diff --git a/src/u43.py b/src/u43.py new file mode 100644 index 0000000..caded56 --- /dev/null +++ b/src/u43.py @@ -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() \ No newline at end of file diff --git a/src/u43.rs b/src/u43.rs index da0f5d9..1852f10 100644 --- a/src/u43.rs +++ b/src/u43.rs @@ -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(); + }) +} \ No newline at end of file diff --git a/src/u45.py b/src/u45.py new file mode 100644 index 0000000..dc967f6 --- /dev/null +++ b/src/u45.py @@ -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() \ No newline at end of file diff --git a/src/u45.rs b/src/u45.rs index da0f5d9..c94c453 100644 --- a/src/u45.rs +++ b/src/u45.rs @@ -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(); + }) +} \ No newline at end of file diff --git a/src/u47.rs b/src/u47.rs index 58713d8..75cdf9a 100644 --- a/src/u47.rs +++ b/src/u47.rs @@ -3,9 +3,7 @@ pub fn main() { } fn rec(num: i32) { - if num >= 1000 { - return; - } + if num >= 1000 { return }; println!("num: {num}"); rec(num + 7) }