<commit_before>#
# Advent of Code
# Day 5: How About a Nice Game of Chess?
#

using Nettle

println("Advent of Code")
println("Day 5: How About a Nice Game of Chess?")
println("")

#DOOR_ID = "abc"
DOOR_ID = "ojvtpuvg"

notFound = true
counter = 0
foundCounter = 0
password = ""

while foundCounter < 8
  testHash = hexdigest("md5",DOOR_ID * string(counter))
  if testHash[1:5] == "00000"
    foundCounter += 1
    password = password * string(testHash[6])
  end

  counter += 1
end

println("The password for $DOOR_ID_EX is $password.")<commit_msg>Day 5 part 2 solution<commit_after>#
# Advent of Code
# Day 5: How About a Nice Game of Chess?
#

using Nettle

println("Advent of Code")
println("Day 5: How About a Nice Game of Chess?")
println("")
println("Part 1")

#DOOR_ID = "abc"
DOOR_ID = "ojvtpuvg"

notFound = true
counter = 0
foundCounter = 0
password = ""

while foundCounter < 8
  testHash = hexdigest("md5",DOOR_ID * string(counter))
  if testHash[1:5] == "00000"
    foundCounter += 1
    password = password * string(testHash[6])
    println("$password")
  end

  counter += 1
end

println("The part 1 password for $DOOR_ID is $password.")

# part 2
println("\nPart2")

notFound = true
counter = 0
foundCounter = 0
password = "--------"

while foundCounter < 8
  testHash = hexdigest("md5",DOOR_ID * string(counter))
  if testHash[1:5] == "00000"
    if isnumber(testHash[6])
      position = parse(string(testHash[6])) + 1
      if position <= 8
        if password[position] == '-'
          password = password[1:position-1] * string(testHash[7]) * password[position+1:end]
          foundCounter += 1
          println("$password")
        end
      end
    end
  end
  counter += 1
end

println("The part 2 password for $DOOR_ID is $password.")
{'fraction_non_alphanumeric': 0.13499716392512762, 'fraction_numerical': 0.03403289846851957, 'mean_word_length': 3.5347043701799485, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7257611', 'n_tokens_mistral': 651, 'n_tokens_neox': 602, 'n_words': 185}