-
-
Save RandyMcMillan/7fc9c9a24e491001597182f2117fc6db to your computer and use it in GitHub Desktop.
nonce_gaps.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=0be53e4d2071475e0fcb26564714d8c1