SHARE
TWEET

Untitled

a guest Jun 19th, 2019 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @implement Coord2d
  2. - (BOOL)isEqual:(id)object {
  3.   Coord2D *other = object;
  4.   return _row == other.row && _col == other.col;
  5. }
  6.  
  7. - (NSUInteger)hash {
  8.   return _row ^ _col;
  9. }
  10.  
  11. @end
  12.      
  13. @implementation Swap
  14. - (BOOL)isEqual:(id)object {
  15.   Swap *other = object;
  16.   return ([_cookieA.coord isEqual:other.cookieA.coord] && [_cookieB.coord isEqual:other.cookieB.coord])
  17.   || ([_cookieA.coord isEqual:other.cookieB.coord] && [_cookieB.coord isEqual:other.cookieA.coord]);
  18. }
  19.  
  20. - (NSUInteger)hash {
  21.   // (A, B) and (B, A) must be interchangable (hash to the same value)
  22.   return (_cookieA.coord.row + _cookieB.coord.row) ^ (_cookieA.coord.col + _cookieB.coord.col);
  23. }
  24. - (NSString *)description
  25. {
  26.   return [NSString stringWithFormat:@"[%@, %@]", _cookieA.coord, _cookieB.coord];
  27. }
  28.  
  29. @end
  30.      
  31. (lldb) po allPossibleSwaps
  32. {(
  33.     [(2, 4), (2, 5)],
  34.     [(1, 1), (2, 1)],
  35.     [(1, 0), (2, 0)],
  36.     [(2, 4), (2, 3)],
  37.     [(1, 2), (2, 2)],
  38.     [(0, 4), (1, 4)],
  39.     [(1, 4), (2, 4)],
  40.     [(1, 4), (1, 5)],
  41.     [(2, 3), (2, 4)]
  42. )}
  43.  
  44. (lldb) po swap
  45. [(1, 4), (2, 4)]
  46.  
  47. (lldb) p [allPossibleSwaps containsObject:swap]
  48. (bool) $64 = false
  49.      
  50. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[0]]
  51. (bool) $41 = true
  52. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[1]]
  53. (bool) $40 = true
  54. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[2]]
  55. (bool) $42 = true
  56. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[3]]
  57. (bool) $39 = true
  58. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[4]]
  59. (bool) $43 = true
  60. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[5]]
  61. (bool) $44 = true
  62. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[6]]
  63. (bool) $45 = false
  64. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[7]]
  65. (bool) $46 = true
  66. (lldb) p [allPossibleSwaps containsObject: allPossibleSwaps.allObjects[8]]
  67. (bool) $47 = true
  68.      
  69. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[0]) isEqual:swap]
  70. (BOOL) $53 = NO
  71. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[1]) isEqual:swap]
  72. (BOOL) $52 = NO
  73. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[2]) isEqual:swap]
  74. (BOOL) $54 = NO
  75. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[3]) isEqual:swap]
  76. (BOOL) $55 = NO
  77. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[4]) isEqual:swap]
  78. (BOOL) $56 = NO
  79. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[5]) isEqual:swap]
  80. (BOOL) $57 = NO
  81. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[6]) isEqual:swap]
  82. (BOOL) $50 = YES
  83. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[7]) isEqual:swap]
  84. (BOOL) $51 = NO
  85. (lldb) p [(Swap *)(allPossibleSwaps.allObjects[8]) isEqual:swap]
  86. (BOOL) $58 = NO
  87.      
  88. (lldb) p ((Swap *)allPossibleSwaps.allObjects[0]).hash
  89. (NSUInteger) $30 = 13
  90. (lldb) p ((Swap *)allPossibleSwaps.allObjects[1]).hash
  91. (NSUInteger) $31 = 1
  92. (lldb) p ((Swap *)allPossibleSwaps.allObjects[2]).hash
  93. (NSUInteger) $32 = 3
  94. (lldb) p ((Swap *)allPossibleSwaps.allObjects[3]).hash
  95. (NSUInteger) $33 = 3
  96. (lldb) p ((Swap *)allPossibleSwaps.allObjects[4]).hash
  97. (NSUInteger) $34 = 7
  98. (lldb) p ((Swap *)allPossibleSwaps.allObjects[5]).hash
  99. (NSUInteger) $35 = 9
  100. (lldb) p ((Swap *)allPossibleSwaps.allObjects[6]).hash
  101. (NSUInteger) $36 = 11
  102. (lldb) p ((Swap *)allPossibleSwaps.allObjects[7]).hash
  103. (NSUInteger) $37 = 11
  104. (lldb) p ((Swap *)allPossibleSwaps.allObjects[8]).hash
  105. (NSUInteger) $65 = 3
  106. (lldb) p swap.hash
  107. (NSUInteger) $66 = 11
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top