Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NOT_A_NUMBER = regexp.MustCompile(`\D`)
var NUMBER = regexp.MustCompile(`\d`)
var STARTS_WITH_WORD_NUMBER = regexp.MustCompile(
`^(one|two|three|four|five|six|seven|eight|nine|zero)`,
)
Functions ¶
func EnhancedParseInput ¶
EnhancedParseInput takes into account that the input may contain words that represent numbers into the parsing.
It returns a slice of ints.
func ParseInput ¶
ParseInput takes a string and returns a slice of ints, ignoring any non-numeric characters.
A number will be added to the slice per line. The number will be the first and last digit of the line.
If the line has only one digit, it will be repeated twice.
func ParseNumber ¶
ParseNumber takes a string, which should be a number, and returns the first and last digit of the number.
If the number is only one digit, it will be repeated twice.
This function panics if the input is not a number.
func Tokenizer ¶
tokenizer is a split function for a Scanner that will recognize numbers and words that represent numbers.
It returns each token as a byte slice and converts words to numbers before returning them.
If the token is not a number or a word, it will return the token as it is.
This function does not return an error.