BenLeggieroNCR

Untitled

Mar 22nd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. An algorithm generates square patterns like this: For any value n, there is a grid of nxn alternating dark-and-light squares, so like-colored squares never touch except for their vertices. These are placed on a background whose color is identical to the light-colored squares, so a dark square alone is surrounded on all sides by a light color. So:
  2.  
  3. n = 1: n = 2: n = 3: n = 4: n = 5:
  4. X X X X X X X X X
  5. X X X X X X
  6. X X X X X X X
  7. X X X X
  8. X X X
  9.  
  10. and so on. Find all groups within these shapes, where a group is defined as a square pattern where all 4 sides are bordered by opposite colors. This function will be called f(x). So:
  11.  
  12. f(1) = 1 dark = 1 total group
  13. Darks:
  14. +-+
  15. |X|
  16. +-+
  17.  
  18. f(2) = 2 dark = 2 total groups
  19. Darks:
  20. +-+
  21. |X|
  22. +-+-+
  23. |X|
  24. +-+
  25.  
  26. f(3) = 5 dark = 5 total groups
  27. Darks:
  28. +-+ +-+
  29. |X| |X|
  30. +-+-+-+
  31. |X|
  32. +-+-+-+
  33. |X| |X|
  34. +-+ +-+
  35.  
  36. f(4) = 8 dark + 2 light + 1 2x2 subgroup = 11 total groups
  37. Darks: Lights: 2x2s:
  38. +-+ +-+
  39. |X| |X| X X X X
  40. +-+-+-+-+ +-+ +---+
  41. |X| |X| X| |X |X |X
  42. +-+-+-+-+ +-+-+ | |
  43. |X| |X| X| |X X| X|
  44. +-+-+-+-+ +-+ +---+
  45. |X| |X| X X X X
  46. +-+ +-+
  47.  
  48. f(5) = 13 dark + 4 light + 4 2x2 subgroups + 1 3x3 subgroup = 22 total groups
  49. Darks: Lights: 2x2s: 3x3s:
  50. +-+ +-+ +-+
  51. |X| |X| |X| X X X X X X X X X
  52. +-+-+-+-+-+ +-+ +-+-+-+ +-----+
  53. |X| |X| X| |X |X| |X| |X X|
  54. +-+-+-+-+-+ +-+-+-+ +-+-+-+ | |
  55. |X| |X| |X| X| |X| |X X| |X| |X X| X |X
  56. +-+-+-+-+-+ +-+-+-+ +-+-+-+ | |
  57. |X| |X| X| |X |X| |X| |X X|
  58. +-+-+-+-+-+ +-+ +-+-+-+ +-----+
  59. |X| |X| |X| X X X X X X X X X
  60. +-+ +-+ +-+
  61.  
  62. And so on.
  63.  
  64.  
  65. THE CHALLENGE IS TO FIND A FUNCTION f THAT WILL FIND THE CORRECT OUTPUT (number of total groups) FOR ANY COUNTING NUMBER x.
Add Comment
Please, Sign In to add comment