puzzle.jl 962 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using BenchmarkTools
  2. using MLStyle
  3. inputfile = joinpath(@__DIR__, "input.txt")
  4. input = split.(readlines(inputfile))
  5. h = Dict("i" => 1, "j" => 1)
  6. t = Dict("i" => 1, "j" => 1)
  7. maxH = 1
  8. maxV = 1
  9. minH = 1
  10. minV = 1
  11. grid = zeros(Int, 350, 350)
  12. function mark(D, i, j, steps)
  13. c = 1
  14. if D == "R"
  15. while c >= steps
  16. for line in input
  17. direction = line[1]
  18. steps = parse(Int, line[2])
  19. println(h)
  20. @match direction begin
  21. "R" => (h["j"] += steps)
  22. "L" => (h["j"] -= steps)
  23. "D" => (h["i"] += steps)
  24. "U" => (h["i"] -= steps)
  25. end
  26. maxH = maximum([h["j"], maxH])
  27. maxV = maximum([h["i"], maxV])
  28. minH = minimum([h["j"], minH])
  29. minV = minimum([h["i"], minV])
  30. end
  31. i, j = (23, 296)
  32. for line in input
  33. @match direction begin
  34. "R" => (h["j"] += steps)
  35. "L" => (h["j"] -= steps)
  36. "D" => (h["i"] += steps)
  37. "U" => (h["i"] -= steps)
  38. end
  39. end