pub struct Day16<'a> { /* private fields */ }
Expand description
2016 Day 16: Calculating a dragon curve checksum.
The checksum is based on the parity of each chunk, and each chunk is the length of the largest power of 2 that divides the checksum’s length.
Using the dragon bit parity function from /u/askalski’s post “How to tame your dragon in under a millisecond” we can calculate the parity of any length of the sequence:
- Calculate how many full repeats of the pattern [Original data][Dragon bit][Reversed & inverted data][Dragon bit] there are, and how far through the pattern the final truncated repeat was.
- Calculate the parity of the full repeats of the original and the reversed & inverted data.
- Calculate the parity of the original data in the truncated repeat, if any.
- Calculate the parity of the reversed & inverted data in the truncated repeat, if any.
- Calculate the parity of all the dragon bits.
- XOR the four calculated parity values together.
This allows computing the parity from the start of the sequence to the end of each chunk, which then can be used to find each chunk’s parity by XORing each parity with the previous one.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Day16<'a>
impl<'a> RefUnwindSafe for Day16<'a>
impl<'a> Send for Day16<'a>
impl<'a> Sync for Day16<'a>
impl<'a> Unpin for Day16<'a>
impl<'a> UnwindSafe for Day16<'a>
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
)