Skip to main content
added 182 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly,  37  3534 bytes

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€a"z0Ṛị“ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_ÄṬ€a"z0Ṛị“/\ ”Y) 

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

Try it online!Try it online!

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€a"z0Ṛị“ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_ÄṬ€a"z0Ṛị“/\ ”Y) - 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: I  - deltas of UpDownSeq -> [v2-v1, v3-v2, ...] H  - halve Ż  - prefix with a zero ⁸_  - subtract from UpDownSeq   -> UpDownSeq with zeros replacing the first of each non-leading run of equal values Ä  - cumulative sums ‘ - increment (this is here to add a trailing new line to each path representation)   Ṭ€ - untruth each (e.g. 3 -> [0,0,1])   a" - zipwise logical AND with UpDownSeq   z0 - transpose with filler zero   Ṛ - reverse   ị“/\ ” - 1-index, cyclically into "/\ "   Y  - tighten to ajoin listwith ofnewline linescharacters 

Jelly,  37  35 bytes

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€a"z0Ṛị“/\ ) 

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

Try it online!

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€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: I  - deltas of UpDownSeq -> [v2-v1, v3-v2, ...] H  - halve Ż  - prefix with a zero ⁸_  - subtract from UpDownSeq   -> UpDownSeq with zeros replacing the first of each non-leading run of equal values Ä  - cumulative sums ‘ - increment (this is here to add a trailing new line to each path representation)   Ṭ€ - 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 

Jelly,  37  34 bytes

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_ÄṬ€a"z0Ṛị“/\ ”Y) 

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

Try it online!

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_ÄṬ€a"z0Ṛị“/\ ”Y) - 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: I - deltas of UpDownSeq -> [v2-v1, v3-v2, ...] H - halve Ż - prefix with a zero ⁸_ - subtract from UpDownSeq -> UpDownSeq with zeros replacing the first of each non-leading run of equal values Ä - 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 "/\ " Y - join with newline characters 
added 182 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly, 37 37  35 bytes

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

Try it online!Try it online!

ḤØ+ṗSÐḟÄAƑ$ƇµŒgḊ€j02;ÄṬ€a"z0Ṛị“ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€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 I -  group runsdeltas of equalUpDownSeq elements -> [v2-v1, v3-v2, ...]  Ḋ€ H - removehalve  first of each  Ż j0  - prefix with a zero  ⁸_ - joinsubtract withfrom zerosUpDownSeq 2;  -> UpDownSeq with prefixzeros areplacing twothe   first of each non-leading run of equal values  Ä  - cumulative sums    - increment (this is here to add a trailing new line to each path representation) Ṭ€ - 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 

Jelly, 37 bytes

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

Try it online!

ḤØ+ṗ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 

Jelly,  37  35 bytes

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€a"z0Ṛị“/\ ”)Ẏ 

Try it online!

ḤØ+ṗSÐḟÄAƑ$ƇµIHŻ⁸_Ä‘Ṭ€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: I - deltas of UpDownSeq -> [v2-v1, v3-v2, ...]   H - halve  Ż   - prefix with a zero  ⁸_ - subtract from UpDownSeq   -> UpDownSeq with zeros replacing the first of each non-leading run of equal values  Ä  - cumulative sums    - increment (this is here to add a trailing new line to each path representation) Ṭ€ - 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 
deleted 132 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading