Advent of Code Challenges
package main

import (
  "flag"
  "fmt"
  "io/ioutil"
  "regexp"
  "strconv"
  "strings"
  "unicode"
)

//var input_file = flag.String("input_file", "puzzle.txt", "Relative file path")
var input_file = flag.String("input_file", "test2.txt", "Relative file path")

func main() {
  flag.Parse()
  bytes, err := ioutil.ReadFile(*input_file)
  fmt.Println("Advent of Code 2023 Day 01")
  if err != nil {
    return
  }
  contents := string(bytes)
  split := strings.Split(contents, "\n")
  split = split[:len(split) - 1]
  //ans_one := part_one(split)
  ans_two := part_two(split)
  //fmt.Printf("Part One: %d\n", ans_one)
  fmt.Printf("Part Two: %d\n", ans_two)
}

func part_one(split []string) int {
  calibration_value := check_digits(split)
  return calibration_value
 }

func part_two(split []string) int {
  calibration_value := 0
  values := []string{}
  for _, s := range split {
    check_string(s)
    values = nil
  }
  fmt.Println()
  fmt.Println(values)
  return calibration_value
}

func check_digits(split []string) int {
 calibration_value := 0
 for _, s := range split {
    tmp := []string{}
    for _, c := range s {
      if unicode.IsDigit(c) {
        tmp = append(tmp, string(c))
      }
    }
    if len(tmp) > 1 {
      first := tmp[0]
      last := tmp[len(tmp)-1]
      value, _ := strconv.Atoi(first + last)
      calibration_value = calibration_value + value
    } else {
      first := tmp[0]
      last := tmp[0]
      value, _ := strconv.Atoi(first + last)
      calibration_value = calibration_value + value
    }
    tmp = nil // clear out slice
  }
  return calibration_value
}

func check_string(s string) {
  nums := []string{"one", "1", "two", "2", "three", "3", "four", "4", "five", "5",
                   "six", "6", "seven", "7", "eight", "8", "nine", "9"}
  pattern := regexp.MustCompile("one|two|three|four|five|six|seven|eight|nine")
  m := pattern.FindAllStringSubmatch(s, -1)
  fmt.Printf("String %s : Pattern %s\n", s, m)
  fmt.Println(nums)
  //return m
}