Advertisement
Guest User

Untitled

a guest
Dec 24th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. if __name__ == "__main__":
  2. with open("input.txt", "r") as f:
  3. data = [
  4. (
  5. int(
  6. not all(
  7. c == "#"
  8. for c in [row for row in schematic.strip().split("\n") if row][
  9. 0
  10. ]
  11. )
  12. ),
  13. [
  14. len(
  15. [
  16. 1
  17. for row in (
  18. range(
  19. 1,
  20. len(
  21. [
  22. row
  23. for row in schematic.strip().split("\n")
  24. if row
  25. ]
  26. ),
  27. )
  28. if all(
  29. c == "#"
  30. for c in [
  31. row
  32. for row in schematic.strip().split("\n")
  33. if row
  34. ][0]
  35. )
  36. else range(
  37. len(
  38. [
  39. row
  40. for row in schematic.strip().split("\n")
  41. if row
  42. ]
  43. )
  44. - 2,
  45. -1,
  46. -1,
  47. )
  48. )
  49. if [row for row in schematic.strip().split("\n") if row][
  50. row
  51. ][col]
  52. == "#"
  53. ]
  54. )
  55. for col in range(
  56. len([row for row in schematic.strip().split("\n") if row][0])
  57. )
  58. ],
  59. )
  60. for schematic in f.read().strip().split("\n\n")
  61. ]
  62.  
  63. print(
  64. len(
  65. set(
  66. tuple(sorted([lock[0], key[0]]))
  67. for lock in [(i, h) for i, (t, h) in enumerate(data) if t == 0]
  68. for key in [(i, h) for i, (t, h) in enumerate(data) if t == 1]
  69. if all(i + j <= 5 for i, j in zip(lock[1], key[1]))
  70. )
  71. )
  72. )
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement