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

Or see the test-suite.

Or see the test-suite.

added 122 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ - Link: integer :7 - integer divide by seven (number of full rainbows) ‘ - increment (the input integer) + - add (gets the number bands) “ vibgyor” - list of characters = " vibgyor" ṁ - mould like the result above (as a range) µ - start a new monadic chain J - range of length ṫ - tail (vectorises) (gets the suffixes) Z - transpose z⁶ - transpose with filler space character   - (together these pad with spaces to the right) U - reverse each - (now we have the left side of the rainbow upside down) ⁸ - chain's left argument, as right argument of... " -  zip with: ; -  concatenation   - (adds the central character)  ŒB - bounce (vectorises at depth 1)   - (reflects each row like [1,2,3,4] -> [1,2,3,4,3,2,1]) Ṛ - reverse (turn the rainbow up the right way) 
:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ - Link: integer :7 - integer divide by seven (number of full rainbows) ‘ - increment (the input integer) + - add (gets the number bands) “ vibgyor” - list of characters = " vibgyor" ṁ - mould like the result above (as a range) µ - start a new monadic chain J - range of length ṫ - tail (vectorises) Z - transpose z⁶ - transpose with filler space character U - reverse each ⁸ - chain's left argument " - zip with: ; - concatenation ŒB - bounce (vectorises at depth 1) Ṛ - reverse 
:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ - Link: integer :7 - integer divide by seven (number of full rainbows) ‘ - increment (the input integer) + - add (gets the number bands) “ vibgyor” - list of characters = " vibgyor" ṁ - mould like the result above (as a range) µ - start a new monadic chain J - range of length ṫ - tail (vectorises) (gets the suffixes) Z - transpose z⁶ - transpose with filler space character   - (together these pad with spaces to the right) U - reverse each - (now we have the left side of the rainbow upside down) ⁸ - chain's left argument, as right argument of... " -  zip with: ; -  concatenation   - (adds the central character)  ŒB - bounce (vectorises at depth 1)   - (reflects each row like [1,2,3,4] -> [1,2,3,4,3,2,1]) Ṛ - reverse (turn the rainbow up the right way) 
added 122 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly, 28 bytes

:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ 

A monadic link accepting an integer which yields a list of lists of characters.

Try it online! (footer joins with newline characters)

How?

:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ - Link: integer :7 - integer divide by seven (number of full rainbows) ‘ - increment (the input integer) + - add (gets the number bands) “ vibgyor” - list of characters = " vibgyor" ṁ - mould like the result above (as a range) µ - start a new monadic chain J - range of length ṫ - tail (vectorises) Z - transpose z⁶ - transpose with filler space character U - reverse each ⁸ - chain's left argument " - zip with: ; - concatenation ŒB - bounce (vectorises at depth 1) Ṛ - reverse 

Jelly, 28 bytes

:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ 

A monadic link accepting an integer which yields a list of lists of characters.

Try it online! (footer joins with newline characters)

Jelly, 28 bytes

:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ 

A monadic link accepting an integer which yields a list of lists of characters.

Try it online! (footer joins with newline characters)

How?

:7+‘“ vibgyor”ṁµṫJZz⁶U;"⁸ŒBṚ - Link: integer :7 - integer divide by seven (number of full rainbows) ‘ - increment (the input integer) + - add (gets the number bands) “ vibgyor” - list of characters = " vibgyor" ṁ - mould like the result above (as a range) µ - start a new monadic chain J - range of length ṫ - tail (vectorises) Z - transpose z⁶ - transpose with filler space character U - reverse each ⁸ - chain's left argument " - zip with: ; - concatenation ŒB - bounce (vectorises at depth 1) Ṛ - reverse 
added 122 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading