Skip to main content
2 of 4
deleted 132 characters in body
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly, 37 bytes

ḤØ+ṗSÐḟÄAƑ$ƇµŒgḊ€j02;ÄṬ€a"z0Ṛị“/\ ”)Ẏ 

A monadic Link that accepts a positive integer and returns a list of lines.

Try it online!

How?

ḤØ+ṗSÐḟÄAƑ$ƇµŒgḊ€j02;ÄṬ€a"z0Ṛị“/\ ”)Ẏ - Link: positive integer, N ḤØ+ṗ - [-1,1] Cartisian power 2N SÐḟ - discard those with non-zero sum ÄAƑ$Ƈ - keep only those with all non-negative cumulative sums µ ) - for each UpDownSeq in that: Œg - group runs of equal elements Ḋ€ - remove first of each j0 - join with zeros 2; - prefix a two Ä - cumulative sums Ṭ€ - untruth each (e.g. 3 -> [0,0,1]) a" - zipwise logical AND with UpDownSeq z0 - transpose with filler zero Ṛ - reverse ị“/\ ” - 1-index, cyclically into "/\ " Ẏ - tighten to a list of lines 
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293