Initial commit

This commit is contained in:
2024-03-11 12:43:52 +02:00
parent 0cc291f3d8
commit a57340adb7
55 changed files with 2961 additions and 1 deletions

1
Rust/code_cycle/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

7
Rust/code_cycle/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "code_cycle"
version = "0.1.0"

View File

@@ -0,0 +1,19 @@
[package]
name = "code_cycle"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.dev.package."*"] # +
opt-level = "z" # Optimize library for size
[profile.release]
#opt-level = 'z' # Optimize for size
opt-level = 3 # Optimize for speed
lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
strip = true # Strip symbols from binary*
[dependencies]

View File

@@ -0,0 +1,18 @@
fn main() {
let total_attempts: i32 = 256*256*256;
let mut successful_attempts: i32 = 0;
for a in 0..256 {
for b in 0..256 {
for c in 0..256 {
if a + b + c > 300 {
successful_attempts += 1;
}
}
}
}
println!("Iterations: {}", total_attempts);
println!("Valid sums: {}", successful_attempts);
println!("Probability: {}", successful_attempts as f32 / total_attempts as f32);
}