Skip to content

Instantly share code, notes, and snippets.

@arialdomartini
Last active September 5, 2024 19:58
Show Gist options
  • Save arialdomartini/c1a3f2309500ffee9934c3e7a9e6407e to your computer and use it in GitHub Desktop.
Save arialdomartini/c1a3f2309500ffee9934c3e7a9e6407e to your computer and use it in GitHub Desktop.
Print Diamond Kata in PBT

Assumptions:

  • Function returns a list of strings.

  • Unless a requirement specifies spaces, it is intented to ignore them (e.g., "list is surrounded by an initial and an ending a" assumes that in this test any space in the initial and ending line is ignored.

  • The order of requirements matter, as it influences the implementation.

  • Requirements are not stricly independent: e.g., 8,10,11,12,13,14 imply 15; 7 and 17 are equivalent.

  • As new requirements are introduced, they complement rather than replace existing ones, which keep being valid.

  • It is indeed possible to design requirements in a way that new specifications replace and supersede certain existing ones. That's not the case of the following requirements.

Requirements

  1. contains only chars up to target
  2. contains all of them
  3. distributed in 2 times minus 1 lines
  4. no line is empty
  5. in first half all lines are disjointed (they don't contain the same characters)
  6. first half is sorted
  7. the whole list is vertically symmetric
  8. each letter but extremes are repeated twice
  9. each line is a palyndrom
  10. center element contains no surrounding spaces
  11. peripheral elements contains no inner spaces
  12. each line contains 1 leading space more than the next one
  13. each line contains 1 trailing space more than the next one
  14. each line contains 2 inner spaces less than the next one
  15. all lines have the same length
  16. The whole list is surrounded by a
  17. halves are symmetric (duplicates 7)
  18. all lines have an odd length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment