Enum advent_solutions::advent2017::day09::Node
[−]
[src]
pub enum Node {
Group(Vec<Node>),
Garbage(usize),
}You sit for a while and record part of the stream (your puzzle input).
The characters represent groups - sequences that begin with { and
end with }. Within a group, there are zero or more other things,
separated by commas: either another group or garbage. Since groups
can contain other groups, a } only closes the most-recently-opened
unclosed group - that is, they are nestable. Your puzzle input
represents a single, large group which itself contains many smaller
ones.
Sometimes, instead of a group, you will find garbage. Garbage begins
with < and ends with >. Between those angle brackets, almost any
character can appear, including { and }. Within garbage, < has
no special meaning.
In a futile attempt to clean up the garbage, some program has canceled
some of the characters within it using !: inside garbage, any
character that comes after ! should be ignored, including <, >,
and even another !.
You don't see any characters that deviate from these rules. Outside garbage, you only find well-formed groups, and garbage always terminates according to the rules above.
Here are some self-contained pieces of garbage:
-
<>, empty garbage. -
<random characters>, garbage containing random characters. -
<<<<>, because the extra<are ignored. -
<{!>}>, because the first>is canceled. -
<!!>, because the second!is canceled, allowing the>to terminate the garbage. -
<!!!>>, because the second!and the first>are canceled. -
<{o"i!a,<{i<a>, which ends at the first>.
Here are some examples of whole streams and the number of groups they contain:
-
{},1group. -
{{{}}},3groups. -
{{},{}}, also3groups. -
{{{},{},{{}}}},6groups. -
{<{},{},{{}}>},1group (which itself contains garbage). -
{<a>,<a>,<a>,<a>},1group. -
{{<a>},{<a>},{<a>},{<a>}},5groups. -
{{<!>},{<!>},{<!>},{<a>}},2groups (since all but the last>are canceled).
Variants
Group(Vec<Node>)Garbage(usize)
Methods
impl Node[src]
pub fn score(&self, level: usize) -> usize[src]
pub fn count_garbage(&self) -> usize[src]
pub fn from_bytes(i: &[u8]) -> IResult<&[u8], Node, u32>
Trait Implementations
impl Clone for Node[src]
fn clone(&self) -> Node[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl PartialEq for Node[src]
fn eq(&self, __arg_0: &Node) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Node) -> bool[src]
This method tests for !=.
impl Eq for Node[src]
impl Debug for Node[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more