Skip to content

Instantly share code, notes, and snippets.

@papaver
Last active February 20, 2022 20:47
Show Gist options
  • Save papaver/1c31af91a299f4c66c531070c5e5e0d4 to your computer and use it in GitHub Desktop.
Save papaver/1c31af91a299f4c66c531070c5e5e0d4 to your computer and use it in GitHub Desktop.

Genetic Chain Mini Challenge

Write a function which takes a single integral value and prints out a spiral to standard output. The input value indicates the size of the grid to create the spiral in. Passing in 5 would result in a spiral generated in a 5x5 grid. The spiral should start on the top left most cell and each edge should be one unit shorter as the spiral winds around and finally ends.

This exercise is a way for you to show us how you think about and break down problems. How you use data structures and implement algorithms. The challenge shouldn't take more than a couple hours, we understand everyone's time is valuable. We are not looking for speed, we are looking for quality. We hope you enjoy the challenge.

Requirements

  • Any language can be used.
  • Code should run without errors.
  • Instructions should be included on how to run/compile the code.
  • Do not use any external libraries.
  • Write the code like you would in a production environment.

Bonus

  • Package up the challenge as a script that takes the input value from the command line.

Example Results:

spiral 5

[* * * * *]
[        *]
[    *   *]
[    * * *]
[         ]

spiral 10

[* * * * * * * * * *]
[                  *]
[    * * * * * *   *]
[    *         *   *]
[    *   * *   *   *]
[    *   *     *   *]
[    *   * * * *   *]
[    *             *]
[    * * * * * * * *]
[                   ]

spiral 15

[* * * * * * * * * * * * * * *]
[                            *]
[    * * * * * * * * * * *   *]
[    *                   *   *]
[    *   * * * * * * *   *   *]
[    *   *           *   *   *]
[    *   *   * * *   *   *   *]
[    *   *   *   *   *   *   *]
[    *   *   *       *   *   *]
[    *   *   * * * * *   *   *]
[    *   *               *   *]
[    *   * * * * * * * * *   *]
[    *                       *]
[    * * * * * * * * * * * * *]
[                             ]
@papaver
Copy link
Author

papaver commented Jan 13, 2021

Please do not post your solutions here. Thanks. - GC Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment