struct Machine {
a: Coords,
b: Coords,
prize: Coords,
}
Fields§
§a: Coords
§b: Coords
§prize: Coords
Implementations§
source§impl Machine
impl Machine
sourcefn get_presses(&self, offset: i64) -> Option<(i64, i64)>
fn get_presses(&self, offset: i64) -> Option<(i64, i64)>
For a machine, solve the pair of linear equations it represents (one in x
and one in y
). Due to integer
division, the results may be rounded. Check they actually solve the equation, returning them if they do,
otherwise return None
as the prize isn’t reachable with a whole number of presses.
See also Cramer’s rule.
sourcefn get_cost_for_prize(&self, offset: i64) -> Option<i64>
fn get_cost_for_prize(&self, offset: i64) -> Option<i64>
Map the number of button presses for a prize, to its cost in tokens
Trait Implementations§
source§impl FromStr for Machine
impl FromStr for Machine
impl Copy for Machine
impl Eq for Machine
impl StructuralPartialEq for Machine
Auto Trait Implementations§
impl Freeze for Machine
impl RefUnwindSafe for Machine
impl Send for Machine
impl Sync for Machine
impl Unpin for Machine
impl UnwindSafe for Machine
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.