-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
756 additions
and
252 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use super::*; | ||
|
||
mod epochs; | ||
mod find; | ||
mod range; | ||
mod supply; | ||
mod traits; | ||
|
||
#[derive(StructOpt)] | ||
pub(crate) enum Command { | ||
Epochs, | ||
Find { | ||
#[structopt(long)] | ||
blocksdir: Option<PathBuf>, | ||
ordinal: Ordinal, | ||
height: u64, | ||
}, | ||
Name { | ||
name: String, | ||
}, | ||
Range { | ||
#[structopt(long)] | ||
name: bool, | ||
height: Height, | ||
}, | ||
Supply, | ||
Traits { | ||
ordinal: Ordinal, | ||
}, | ||
} | ||
|
||
impl Command { | ||
pub(crate) fn run(self) -> Result<()> { | ||
match self { | ||
Self::Epochs => epochs::run(), | ||
Self::Find { | ||
blocksdir, | ||
ordinal, | ||
height, | ||
} => find::run(blocksdir.as_deref(), ordinal, height), | ||
Self::Name { name } => name::run(&name), | ||
Self::Range { height, name } => range::run(height, name), | ||
Self::Supply => supply::run(), | ||
Self::Traits { ordinal } => traits::run(ordinal), | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use super::*; | ||
|
||
pub(crate) fn run() -> Result { | ||
for ordinal in Epoch::STARTING_ORDINALS { | ||
println!("{}", ordinal); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use super::*; | ||
|
||
pub(crate) fn run(height: Height, name_range: bool) -> Result { | ||
let mut start = 0; | ||
|
||
for n in 0..height.n() { | ||
let subsidy = Height(n).subsidy(); | ||
|
||
if subsidy == 0 { | ||
break; | ||
} | ||
|
||
start += subsidy; | ||
} | ||
|
||
let end = start + height.subsidy(); | ||
|
||
if name_range { | ||
let (start, end) = match (Ordinal::new_checked(start), Ordinal::new_checked(end)) { | ||
(Some(start), Some(end)) => (start.name(), end.name()), | ||
(Some(start), None) => (start.name(), start.name()), | ||
(None, None) => (Ordinal::LAST.name(), Ordinal::LAST.name()), | ||
(None, Some(_)) => unreachable!(), | ||
}; | ||
println!("[{},{})", start, end); | ||
} else { | ||
println!("[{},{})", start, end); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use super::*; | ||
|
||
pub(crate) fn run(ordinal: Ordinal) -> Result { | ||
let n = ordinal.n(); | ||
|
||
if n % 2 == 0 { | ||
println!("even"); | ||
} else { | ||
println!("odd"); | ||
} | ||
|
||
let isqrt = n.integer_sqrt(); | ||
if isqrt * isqrt == n { | ||
println!("square"); | ||
} | ||
|
||
let icbrt = n.integer_cbrt(); | ||
if icbrt * icbrt * icbrt == n { | ||
println!("cube"); | ||
} | ||
|
||
let digits = n.to_string().chars().collect::<Vec<char>>(); | ||
|
||
let pi = std::f64::consts::PI.to_string().replace('.', ""); | ||
let s = n.to_string(); | ||
if s == pi[..s.len()] { | ||
println!("pi"); | ||
} | ||
|
||
if digits.chunks(2).all(|chunk| chunk == ['6', '9']) { | ||
println!("nice"); | ||
} | ||
|
||
if digits.iter().all(|c| *c == '7') { | ||
println!("angelic"); | ||
} | ||
|
||
println!( | ||
"luck: {}/{}", | ||
digits.iter().filter(|c| **c == '8').count() as i64 | ||
- digits.iter().filter(|c| **c == '4').count() as i64, | ||
digits.len() | ||
); | ||
|
||
println!("population: {}", ordinal.population()); | ||
|
||
println!("name: {}", ordinal.name()); | ||
|
||
if let Some(character) = char::from_u32((n % 0x110000) as u32) { | ||
println!("character: {:?}", character); | ||
} | ||
|
||
println!("height: {}", ordinal.height()); | ||
|
||
if ordinal.subsidy_position() == 0 { | ||
println!("shiny"); | ||
} | ||
|
||
if ordinal.height() == 124724 { | ||
if ordinal == 623624999999999 { | ||
println!("illusive"); | ||
} else { | ||
println!("cursed"); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.