Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created February 18, 2026 13:13
Show Gist options
  • Select an option

  • Save rust-play/0be53e4d2071475e0fcb26564714d8c1 to your computer and use it in GitHub Desktop.

Select an option

Save rust-play/0be53e4d2071475e0fcb26564714d8c1 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let mut nonces = vec![0u128];
let mut counter = 0u64;
nonces.pop();
// First Gap: 1.5 x 10^9 to 2.0 x 10^9
//counter += (2.0e9 - 1.5e9) as u64;
for nonce in 1_500/*_000_000*/..=3_000/*_000_000*/ {
nonces.push(nonce*1_000_000);
counter = counter+1;
};
//for nonce in nonces.clone() {println!("{}",nonce);}
// Second Gap: 2.5 x 10^9 to 3.0 x 10^9
//counter += (3.0e9 - 2.5e9) as u64;
for nonce in 2_500/*_000_000*/..=3_000/*_000_000*/ {
nonces.push(nonce*1_000_000);
counter = counter+1;
};
//for nonce in nonces.clone() {println!("{}",nonce);}
// Third Gap: 3.5 x 10^9 to 4.0 x 10^9
//counter += (4.0e9 - 3.5e9) as u64;
for nonce in 3_500/*_000_000*/..=4_000/*_000_000*/ {
nonces.push(nonce*1_000_000);
counter = counter+1;
};
for nonce in nonces.clone() {print!("{} ",nonce);}
print!("\ncount={} ", counter);
// Each gap has a size of 0.5 x 10^9
// A more concise way to represent the total count is to sum the number of gaps and multiply by the gap size.
// let gap_size = 0.5e9 as u64;
// let number_of_gaps = 3;
// let total_count = gap_size * number_of_gaps;
// println!("Total count from the first method: {}", counter);
// println!("Total count from the second method: {}", total_count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment