format and u9
This commit is contained in:
parent
b8cfc80d1b
commit
f1b2a8c9ba
11 changed files with 114 additions and 84 deletions
16
src/main.rs
16
src/main.rs
|
@ -1,12 +1,4 @@
|
||||||
pub mod u1;
|
pub mod u1;
|
||||||
pub mod u2;
|
|
||||||
pub mod u3;
|
|
||||||
pub mod u4;
|
|
||||||
pub mod u5;
|
|
||||||
pub mod u6;
|
|
||||||
pub mod u7;
|
|
||||||
pub mod u8;
|
|
||||||
pub mod u9;
|
|
||||||
pub mod u10;
|
pub mod u10;
|
||||||
pub mod u11;
|
pub mod u11;
|
||||||
pub mod u12;
|
pub mod u12;
|
||||||
|
@ -17,6 +9,7 @@ pub mod u16;
|
||||||
pub mod u17;
|
pub mod u17;
|
||||||
pub mod u18;
|
pub mod u18;
|
||||||
pub mod u19;
|
pub mod u19;
|
||||||
|
pub mod u2;
|
||||||
pub mod u20;
|
pub mod u20;
|
||||||
pub mod u21;
|
pub mod u21;
|
||||||
pub mod u22;
|
pub mod u22;
|
||||||
|
@ -27,6 +20,7 @@ pub mod u26;
|
||||||
pub mod u27;
|
pub mod u27;
|
||||||
pub mod u28;
|
pub mod u28;
|
||||||
pub mod u29;
|
pub mod u29;
|
||||||
|
pub mod u3;
|
||||||
pub mod u30;
|
pub mod u30;
|
||||||
pub mod u31;
|
pub mod u31;
|
||||||
pub mod u32;
|
pub mod u32;
|
||||||
|
@ -37,6 +31,7 @@ pub mod u36;
|
||||||
pub mod u37;
|
pub mod u37;
|
||||||
pub mod u38;
|
pub mod u38;
|
||||||
pub mod u39;
|
pub mod u39;
|
||||||
|
pub mod u4;
|
||||||
pub mod u40;
|
pub mod u40;
|
||||||
pub mod u41;
|
pub mod u41;
|
||||||
pub mod u42;
|
pub mod u42;
|
||||||
|
@ -46,6 +41,11 @@ pub mod u45;
|
||||||
pub mod u46;
|
pub mod u46;
|
||||||
pub mod u47;
|
pub mod u47;
|
||||||
pub mod u48;
|
pub mod u48;
|
||||||
|
pub mod u5;
|
||||||
|
pub mod u6;
|
||||||
|
pub mod u7;
|
||||||
|
pub mod u8;
|
||||||
|
pub mod u9;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -10,7 +10,6 @@ pub fn main() {
|
||||||
std::io::stdin().read_line(&mut input).unwrap();
|
std::io::stdin().read_line(&mut input).unwrap();
|
||||||
println!("opacny retazec: {}", opacne_poradie(&input));
|
println!("opacny retazec: {}", opacne_poradie(&input));
|
||||||
input.clear();
|
input.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opacne_poradie(input: &String) -> String {
|
fn opacne_poradie(input: &String) -> String {
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use std::ffi::CString;
|
|
||||||
use pyo3::ffi::c_str;
|
use pyo3::ffi::c_str;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
use std::ffi::CString;
|
||||||
|
|
||||||
static code: &'static str = include_str!("u2.py");
|
static code: &'static str = include_str!("u2.py");
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
let c = CString::new(code.as_bytes()).unwrap();
|
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();
|
let activator =
|
||||||
|
PyModule::from_code(py, c.as_c_str(), c_str!("main.py"), c_str!("main")).unwrap();
|
||||||
activator.call_method("main", (), None).unwrap();
|
activator.call_method("main", (), None).unwrap();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
16
src/u3.rs
16
src/u3.rs
|
@ -1,10 +1,16 @@
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
std::io::stdin().read_line(&mut input).unwrap();
|
std::io::stdin().read_line(&mut input).unwrap();
|
||||||
let a: u128 = input.trim().parse().expect("Ocakavali sme prirodzene cislo");
|
let a: u128 = input
|
||||||
|
.trim()
|
||||||
|
.parse()
|
||||||
|
.expect("Ocakavali sme prirodzene cislo");
|
||||||
input.clear();
|
input.clear();
|
||||||
std::io::stdin().read_line(&mut input).unwrap();
|
std::io::stdin().read_line(&mut input).unwrap();
|
||||||
let b: u128 = input.trim().parse().expect("ocakavali sme prirodzene cislo");
|
let b: u128 = input
|
||||||
|
.trim()
|
||||||
|
.parse()
|
||||||
|
.expect("ocakavali sme prirodzene cislo");
|
||||||
input.clear();
|
input.clear();
|
||||||
|
|
||||||
devidable(a, b);
|
devidable(a, b);
|
||||||
|
@ -12,7 +18,11 @@ pub fn main() {
|
||||||
|
|
||||||
fn devidable(a: u128, b: u128) {
|
fn devidable(a: u128, b: u128) {
|
||||||
for i in a..b + 1 {
|
for i in a..b + 1 {
|
||||||
let digit_sum: u128 = i.to_string().chars().map(|c| c.to_digit(10).unwrap() as u128).sum();
|
let digit_sum: u128 = i
|
||||||
|
.to_string()
|
||||||
|
.chars()
|
||||||
|
.map(|c| c.to_digit(10).unwrap() as u128)
|
||||||
|
.sum();
|
||||||
if digit_sum % 3 == 0 {
|
if digit_sum % 3 == 0 {
|
||||||
println!("{}", i);
|
println!("{}", i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ pub fn main() {
|
||||||
let out = fun(a, b);
|
let out = fun(a, b);
|
||||||
println!("{}", out);
|
println!("{}", out);
|
||||||
|
|
||||||
let mut file = std::fs::OpenOptions::new().write(true).create(true).open("output.txt").unwrap();
|
let mut file = std::fs::OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.open("output.txt")
|
||||||
|
.unwrap();
|
||||||
file.write_all(out.to_string().as_bytes()).unwrap();
|
file.write_all(out.to_string().as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use std::ffi::CString;
|
|
||||||
use pyo3::ffi::c_str;
|
use pyo3::ffi::c_str;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
use std::ffi::CString;
|
||||||
|
|
||||||
static code: &'static str = include_str!("u6.py");
|
static code: &'static str = include_str!("u6.py");
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
let c = CString::new(code.as_bytes()).unwrap();
|
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();
|
let activator =
|
||||||
|
PyModule::from_code(py, c.as_c_str(), c_str!("main.py"), c_str!("main")).unwrap();
|
||||||
activator.call_method("main", (), None).unwrap();
|
activator.call_method("main", (), None).unwrap();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub fn main() {
|
||||||
for i in (a..=b).step_by(2) {
|
for i in (a..=b).step_by(2) {
|
||||||
print!("{} ", i);
|
print!("{} ", i);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"n" | "neparne" => {
|
"n" | "neparne" => {
|
||||||
let a = if a % 2 == 1 { a } else { a + 1 };
|
let a = if a % 2 == 1 { a } else { a + 1 };
|
||||||
for i in (a..=b).step_by(2) {
|
for i in (a..=b).step_by(2) {
|
||||||
|
|
17
src/u9.rs
17
src/u9.rs
|
@ -1 +1,16 @@
|
||||||
pub fn main() {}
|
pub fn main() {
|
||||||
|
let mut input = String::new();
|
||||||
|
std::io::stdin().read_line(&mut input).unwrap();
|
||||||
|
//i, í, y, ý, I, Í, Y, Ý
|
||||||
|
let input = input
|
||||||
|
.trim()
|
||||||
|
.replace("i", "_")
|
||||||
|
.replace("í", "_")
|
||||||
|
.replace("y", "_")
|
||||||
|
.replace("ý", "_")
|
||||||
|
.replace("I", "_")
|
||||||
|
.replace("Í", "_")
|
||||||
|
.replace("Y", "_")
|
||||||
|
.replace("Ý", "_");
|
||||||
|
println!("{}", input);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue