Skip to content

Instantly share code, notes, and snippets.

@jaymoid
Last active July 30, 2018 20:00
Show Gist options
  • Save jaymoid/b41587ad4ff607d01d1d0ac2486acfea to your computer and use it in GitHub Desktop.
Save jaymoid/b41587ad4ff607d01d1d0ac2486acfea to your computer and use it in GitHub Desktop.
Diamond Kata, Leeds Code Dojo

Leeds Code Dojo Strong Pair Programming, Diamond Kata

(Extended/Inspired from Seb Rose's Diamond kata at http://cyber-dojo.org/ )

1. Sparkly Diamonds (New to the code dojo / programming?)

Given a number, print a diamond made up of asterisks (*)

The number passed to your function indicates the number of rows of stars to print until it reaches the widest point of the diamond.

For example:

printDiamond(3);

    *
   * *
  *   *
   * *
    *

printDiamond(4):

     *
    * *
   *   *
  *     *
   *   *
    * *
     *

2. Alphabet Diamonds (Regulars start here)

printDiamond('E')

    A
   B B
  C   C
 D     D
E       E
 D     D
  C   C
   B B
    A

printDiamond('C')

  A
 B B
C   C
 B B
  A

3. Mega Alpha Diamonds

printDiamond('F')

          F
        F E F
      F E D E F
    F E D C D E F
  F E D C B C D E F
F E D C B A B C D E F
  F E D C B C D E F
    F E D C D E F
      F E D E F
        F E F
          F

4. Just go for Coffee already!

printDiamond('D')

        A
       B L
      C   K
     D     J
      E   I
       F H
        G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment