Skip to main content
2 of 7
edited tags
Riker
  • 7.9k
  • 4
  • 39
  • 73

Make Some Snow!

Your task: generate a Koch snowflake to the nth depth. You do not need to make a complete Koch snowflake, just one side of the starting triangle. Wikipedia on Koch flakes: https://en.wikipedia.org/wiki/Koch_snowflake.

Rules:

  • The program must generate one side of the Koch snowflake to the nth depth.
  • Output may be ASCII or graphical.
  • You may generate the whole snowflake; this is not required.
  • Standard rules for input/output and loopholes and stuff apply.
  • Whitespace does not matter, as long as it all characters are in the right place. (ASCII)
  • Shortest code wins!

Test cases:

n=0: ASCII: _, Graphical: koch snowflake iteration 0

n=1: ASCII: _/\_, Graphical: koch snowflake iteration 1

n=2: ASCII:

    _/\_
    \  /
_/\_/  \_/\_

Graphical: koch snowflake iteration 2

n=3: ASCII:

               _/\_
               \  /
           _/\_/  \_/\_
           \          /
           /_        _\
             \      /
    _/\_    _/      \_    _/\_
    \  /    \        /    \  /
_/\_/  \_/\_/        \_/\_/  \_/\_

Graphical: koch snowflake iteration 3

I hope this makes sense.

sporkl
  • 6.9k
  • 1
  • 27
  • 63