title: Backwards Alphabet Triangle

text:
# Question
Title: Backwards Alphabet Triangle
Without taking any input, output this exact text:

```
                         A
                        B A
                       C B A
                      D C B A
                     E D C B A
                    F E D C B A
                   G F E D C B A
                  H G F E D C B A
                 I H G F E D C B A
                J I H G F E D C B A
               K J I H G F E D C B A
              L K J I H G F E D C B A
             M L K J I H G F E D C B A
            N M L K J I H G F E D C B A
           O N M L K J I H G F E D C B A
          P O N M L K J I H G F E D C B A
         Q P O N M L K J I H G F E D C B A
        R Q P O N M L K J I H G F E D C B A
       S R Q P O N M L K J I H G F E D C B A
      T S R Q P O N M L K J I H G F E D C B A
     U T S R Q P O N M L K J I H G F E D C B A
    V U T S R Q P O N M L K J I H G F E D C B A
   W V U T S R Q P O N M L K J I H G F E D C B A
  X W V U T S R Q P O N M L K J I H G F E D C B A
 Y X W V U T S R Q P O N M L K J I H G F E D C B A
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A

```

## Rules

* Output can be given by any convenient method.
* You can print it to STDOUT or return it as a function result.
* Either a full program or a function are acceptable.
* A single trailing newline is acceptable, but no other formatting changes are allowed.
* Capital letters are required.
* Standard loopholes are forbidden.
* This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

# Answer
# Haskell, 53 bytes

```
[tail$do c<-reverse a;' ':[c|c<=d]|d<-a]
a=['A'..'Z']

```

Try it online!

This uses that each line has exactly 25 spaces. So, instead of separately handling the prefix spaces and the spaces between letters, we take 26 spaces, and decide whether to put a letter after each. This unfortunately gives one extra leading space, which we remove.

---

**54 bytes**

```
foldl(\m c->map(' ':)m++[c:' ':last m])["A"]['B'..'Z']

```

Try it online!

---

**55 bytes**

```
"A"%['B'..'[']
s%(h:t)=((' '<$t)++s):(h:' ':s)%t
s%_=[]

```

Try it online!
> 8 votes

# Answer
# C (gcc),  ~~82 79 77 75~~  74 bytes

*Saved 2 bytes thanks to @ceilingcat*
*Saved 1 byte thanks to @gastropner*

Derived from my 2nd JS answer.

```
f(x,y,s){for(x=0,y=25;~y;putchar(s>51?x=!y--,13:s&x>y?90-s/2:32))s=++x+y;}

```

Try it online!

### How?

We start with \\$x=0\\$ and \\$y=25\\$. We increment \\$x\\$ at the beginning of the line. We set \\$x\\$ to \\$0\\$ and decrement \\$y\\$ at the end of the line, which is reached when \\$x+y=52\\$. We stop when \\$y=-1\\$.

This gives:

```
   0        1         2         3
   123456789012345678901234567890...
25 .........................A
24 ........................B.A
23 .......................C.B.A
22 ......................D.C.B.A
21 .....................E.D.C.B.A
 ⋮

```

We append a letter when \\$x+y\\$ is odd and \\$x\\$ is greater than \\$y\\$, or a space otherwise.

The ASCII code of the letter at \\$(x,y)\\$ is given by:

$$90-\left\lfloor\frac{x+y}{2}\right\rfloor, (x+y)\equiv 1 \pmod 2$$
> 7 votes

# Answer
# Charcoal, ~~7~~ 9 bytes

```
ＵＴ↙Ｅα…α⊕κ

```

Try it online! Link is to verbose version of code. Explanation:

```
  α     Uppercase alphabet
 Ｅ      Map over characters
    α   Uppercase alphabet
   …    Truncated to length
      κ Current index
     ⊕  Incremented
↙       Output with a 135° rotation

```

Effectively, this starts with the `A` in the bottom right corner, then works its way to the top left printing longer and longer prefixes of the uppercase alphabet each time, each prefix being printed towards the bottom left. The `ＵＴ` simply suppresses Charcoal's default rectangular output, apparently needed for this question for some reason.
> 6 votes

# Answer
# V (vim), ~~16, 15~~, 12 bytes

```
¬ZAòé hòòxâÄ

```

Try it online!

Hexdump:

```
00000000: ac5a 41f2 e920 68f2 f278 e2c4            .ZA.. h..x..

```

Thanks to Kritixi Lithos for helping me golf a few off.

Explanation:

```
¬ZA                 " Insert every character between 'Z' and 'A'
                    " The cursor is on the 'A'
   ò         ò      " Recursively...
    é<space>        "   Insert a space
            h       "   Move back one character
                    "   If we're on the first column, this will break the loop
              ò     " Recursively...
               x    "   Delete the current character
                â   "   Stop looping if there's only one non-whitespace character on this line
                 Ä  "   Duplicate this line upward

```
> 5 votes

# Answer
# Bash \+ common GNU tools, 42

```
echo {Z..A}|sed -n ':l;p;s/[B-Z]//;tl'|tac

```

### Explanation

* `echo {Z..A}` is a bash brace expansion that outputs `Z Y X W V U T S R Q P O N M L K J I H G F E D C B A`
* The sed expression is a loop that:
    + `:l` Define a label l
    + `p`rint the current pattern space
    + `s/[B-Z]//` match the first instance of B-Z and replace it with ""
    + `tl` if a match occurred above, jump back to label l
    + (implicit) otherwise quit. `-n` suppresses implicit output of the pattern space at the end of line processing.
* The output of the sed is the required triangle, but upside down. The `tac` reverses it line-by-line to give the required output.

Try it online!
> 5 votes

# Answer
# Poetic, 686 bytes

```
the a-b-c corner
i was a child of ten or eleven
i said i am smart,i am likely to get an answer
i got a chance to read papers,novels or some old poetry
i read in class
as i read,i paused a bit
the words,i do admit,were a huge issue
please tutor,i said,i desire a nap
i truly do not
i fibbed
i am hiding a r-real g-great l-lie,a secret
i am idiot,i cant t-truly r-r-read
i think im reading,really im no smart reader
i need a lesson,i say,i really do
not a whole lot of people are helping teach me
i want a tutor,i say,i really want someone smart
i call a skilled tutor on my phone
as i call a person,i see a letter key,then i press down
it worked!i see a letter shape
amazing start for me

```

Try it online!

Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.
> 5 votes

# Answer
# , 34 bytes

```
((32#~26-#)<@u:@,32,@,.65+|.)\i.26

```

Try it online!
> 4 votes

# Answer
# PowerShell, 37 bytes

```
25..0|%{' '*$_+[char[]]((90-$_)..65)}

```

Try it online!
> 4 votes

# Answer
# , 78 72 63 bytes

```
for(i in 1:26){cat(strrep(" ",26-i));cat(LETTERS[i:1],fill=52)}

```

Try it online!

Nothing fancy. First print spaces, then print letters.

Improvement inspired by https://codegolf.stackexchange.com/a/195078/89953, but cannot comment there because of reputation.
> 4 votes

# Answer
# Python 2, 53 bytes

```
i=26
s='A'
while i:i-=1;print' '*i+s;s='%c '%(91-i)+s

```

Try it online!

We take care not to introduce any trailing spaces, which means avoiding `center` and also avoiding adding a space with `A` for the first row.
> 3 votes

# Answer
# Ruby, ~~57~~ 54 bytes

```
?A.upto(?Z){puts' '*(90-_1.ord)+[*?A.._1].reverse*' '}

```

Attempt This Online!
> 3 votes

# Answer
# Python 3, 76 75 bytes:

-1 byte thanks to @pppery

```
for i in range(27):print((27-i)*' '+' '.join(chr(64+i-x)for x in range(i)))

```

Try it online.

Another **75 bytes**:

```
for i in range(27):print(' '.join(chr(64+i-x)for x in range(i)).center(51))

```

Try it online.
> 3 votes

# Answer
# Canvas, 13 bytes

```
Ｚ［± ＊ＺＬ³－ ××］

```

Try it here!

Explanation:

```
Z[± *ZL³- ××]
Z[          ] map over the prefixes of the uppercase alphabet
  ±             reverse the current prefix
    *           interleave it with spaces
     ZL³-       substract the loop index from 26
          ×     that many spaces
           ×    prepend the spaces to the prefix

```

7 bytes with padding with spaces. yep, 2x bytecount to "remove" them..
> 2 votes

# Answer
# Wolfram Language (Mathematica), 76 bytes

```
Array[StringRiffle[Reverse@ToUpperCase@Alphabet[][[;;#]]]&,26]~Column~Center

```
> 2 votes

# Answer
# Jelly, 13 bytes

```
ØALḶ⁶ẋṚżUK$ƤY

```

Try it online!

A full program that prints the desired output to STDOUT.

## Explanation

```
ØA            | Uppercase letters
  L           | Length (26)
   Ḷ          | Lowered range (0..25)
    ⁶ẋ        | Space that many times (vectorises)
      Ṛ       | Reverse list
       ż      | Zip with:
          $Ƥ  | - Following applied to each prefix of the uppercase letters:
        U     |   - Reverse
         K    |   - Join with spaces
            Y | Join with newlines

```

Without the final Y, a list of lists of Jelly strings woulf be returned, with the spaces and letters in separate sublists. As such, I’ve gone with joining the outer list with newlines and relying on Jelly’s default printing method to produce the correct output.
> 2 votes

# Answer
# Retina 0.8.2, ~~57~~ ~~52~~ 42 bytes

```
T`L`_L
}`^
Z
.
$.`$* $&$'¶
\B\w
 $&
O`
G`.

```

Try it online! Explanation:

```
T`L`_L

```

Move all of the letters so far one step backwards in the alphabet, but delete any `A`.

```
^
Z

```

Prefix a `Z` to the current string.

```
}`

```

Repeat the above until the transformation becomes idempotent. This happens when the string is the entire alphabet; the `A` is deleted, the `Z-B` get transliterated into `Y-A`, and another `Z` is prefixed.

```
.
$.`$* $&$'¶

```

Turn the alphabet into a triangle.

```
\B\w
 $&

```

Space out the letters.

```
O`

```

Get the lines in the correct order.

```
G`.

```

Remove an extraneous trailing newline. (Retina 0.8.2 always adds a trailing newline, so there would have been two; had I used Retina 1 I could have claimed that newline as my allowed newline.)
> 2 votes

# Answer
# Japt `-R`, 14 bytes

```
;Båi ®¬¸Ãû
mx1

```

Saved a byte thanks to @Shaggy.

Gained 4 bytes due to fixing a bug.

Test it
> 2 votes

# Answer
# K (oK), ~~34~~ 33 bytes

-1 byte thanks to ngn

```
(-26-!26)$`c${,/32,'|65+!x}'1+!26

```

Try it online!
> 2 votes

# Answer
# K (ngn/k), 27 bytes

```
1_|^\(," "/+,a),a:`c$90-!26

```

Try it online!

`!26` is `0 1`..`25`

`90-!26` is `90 89`..`65`

``c$` convert to chars: `"ZY`..`A"`

`a:` assign to `a`

`(,`..`),` prepend as a single element

* `+,a` flip enlist, i.e. make each char a length-1 string: `(,"Z";,"Y";`..`;,"A")`
* `" "/` join with spaces (in some dialects of k this may be `" "/:`)

`^\` without-scan, i.e. start with `"Z Y`..`A"`, then remove `"Z"`, then remove `"Y"`, etc, and collect intermediate results

`|` reverse

`1_` drop the first, as it's an all-spaces string
> 2 votes

# Answer
# Java (JDK), 82 bytes

```
v->{var x="";for(char c=64;++c<91;)System.out.printf("%"+(c-38)+"s%n",x=c+" "+x);}

```

Try it online!

## Credits
> 2 votes

# Answer
# 05AB1E, 8 bytes

```
ASuηí».c

```

Try it online!

```
A           # push the alphabet, "abcdefghijklmnopqrstuvwxyz"
 S          # split to a list of chars
  u         # uppercase
   η        # prefixes
    í       # reverse each
     »      # join by newlines, joining sublists by spaces
      .c    # center

```
> 2 votes

# Answer
# Forth (gforth), 62 bytes

```
: f 25 for i spaces 25 i - for i 65 + emit ."  "next cr next ;

```

Try it online!

### Code explanation

```
: f            \ start a new word definition
  25 for       \ loop from 25 to 0
    i spaces   \ print loop-index spaces
    25 i - for \ loop from (25 - loop-index) to 0
      i 65 +   \ add inner loop-index to 65 (ascii 'A')
      emit     \ output ascii char for value
      ."  "    \ output a single space
    next       \ end inner loop
    cr         \ output a newline
  next         \ end outer loop
;              \ end word definition

```
> 2 votes

# Answer
# k4, 24 bytes

```
(-26-!26)$|:',\.Q.A,'" "

```

explanation:

```
               .Q.A,'" " /append space to each capital letter ("A ";"B "; "C "; ... )
             ,\          /join scan, join each element successively and return intermediate results ("A ";"A B ";"A B C "; ... )
          |:'            /reverse each
(-26-!26)$               /left-pad each with -26 -27 -28 ...

```

run like:

```
q)k)(-26-!26)$|:',\.Q.A,'" "
"                         A"
"                        B A"
"                       C B A"
"                      D C B A"
..

```
> 2 votes

# Answer
# Retina, 35 bytes

```

25*

.
Y`.`RL
L^$w`^(..)*
$#1* $'

```

Try it online! Explanation:

```

25*

```

Insert 25 spaces.

```

.

```

Insert `.`s in all available positions. This results in 26 `.`s, because both the start and end can have a `.` inserted.

```
Y`.`RL

```

Cyclically transliterate the `.`s using a reversed uppercase alphabet.

```
L^$w`^(..)*

```

List all (necessarily overlapping) prefixes of even numbers of characters, in reverse order (i.e. longest prefix to shortest).

```
$#1* $'

```

For each prefix, output the number of pairs as a run of spaces (effectively deleting the letters) plus its suffix.
> 2 votes

# Answer
# SNOBOL4 (CSNOBOL4), ~~103~~ ~~93~~ 77 bytes

```
N	&UCASE B LEN(1) . B @X :F(END)
	A =B ' ' A
	OUTPUT =LPAD(A,26 + X) :(N)
END

```

Try it online!
> 2 votes

# Answer
# Excel, 79 bytes

```
=LET(k,ROW(1:26),REPT(" ",26-k)&RIGHT(CONCAT(" "&CHAR(91-TRANSPOSE(k))),2*k-1))

```

Explanation

```
k,ROW                                                         ' k = 1..26
REPT(" ",26-k)&RIGHT(CONCAT(" "&CHAR(91-TRANSPOSE(k))),2*k-1) ' Final Calculation
REPT(" ",26-k)                                                ' 26-k spaces
                     CONCAT(" "&CHAR(91-TRANSPOSE(k)))        ' " Z Y ...
               RIGHT(                                 ,2*k-1) ' Right 2k-1 characters

```
> 2 votes

# Answer
# vim, 42 41 bytes

```
:set nf=alpha
aZ<ESC>qqYp<C-x>q24@qVggJqqYPxq24@q

```

`<ESC>` is 0x1b, `<C-x>` is 0x18, `<NL>` is 0x0a.

## Annotated

```
:set nf=alpha   # make <C-x> work with letters
aZ<ESC>         # put Z in buffer
qqYp<C-x>q      # Record macro q: Append a line with the previous letter
24@q            # ...and execute until we have all the letters
VggJ            # combine all lines into "Z Y X ... C B A"
qqYPxq         # Record macro q: Copy line to previous line, delete first char
24@q            # ...and execute until we have all the rows

```

Try it online!
> 2 votes

# Answer
# Scratch, ~~256~~ 240 bytes

-16 thanks to @Lyxal because I can't read! XD

Try it online!

At first, I thought it would be shorter to add each string manually, but I was very wrong! It doesn't look very good outside of monospace fonts though...

```
delete all of[P v
set[A v]to[ABCDEFGHIJKLMNOPQRSTUVWXYZ
set[C v]to(25
set[L v]to(
repeat(26
set[S v]to(
repeat(C
set[S v]to(join(S)(
change[C v]by(-1
set[L v]to(join(join(letter(round((length of(L))/(2)))of(A))( ))(L
add(join(S)(L))to[P v

```
> 2 votes

# Answer
# JavaScript (Node.js),  ~~65~~  63 bytes

*Saved 2 bytes thanks to @l4m2*

```
f=(n=26,s=`A
`)=>n--?''.padEnd(n)+s+f(n,Buffer([91-n,32])+s):''

```

Try it online!

---

# JavaScript (Node.js), 79 bytes

More maths, more bytes.

```
f=(x=y=0)=>y<26?Buffer([x<y+26?y+x++&x>25-y?156-x+y>>1:32:(x=!++y,13)])+f(x):''

```

Try it online!
> 1 votes

# Answer
# Zsh, ~~46~~ 43 bytes

***-3 bytes** from @pxeger using `eval` instead of a for loop*

```
eval a={A..Z}'\ $a;echo ${(l:26+i++:)a%?};'

```

Try it online!

The `eval` expands to:

```
a=A\ $a;echo ${(l:26+i++:)a%?}; a=B\ $a;echo ${(l:26+i++:)a%?}; ...

```

Which is the same as the for loop from the second 46-byte solution below:

---

**Originals:**

```
for c ({A..Z})a=($c $a)&&echo ${(l:25-i++:)}$a

```

Try it online!

Abuses arrays implicitly joining on spaces. `l:expr:` pads on the `l`eft with spaces until at `expr` characters wide. Putting parameter expansion flags with no parameter like this causes them to operate on an empty string.

---

Alternate **46 byte** solution, using a string with `${a%postfixremoval}` instead. Note that here we increment the padding width to accommodate the growing total string length.

```
for c ({A..Z})a=$c\ $a&&echo ${(l:26+i++:)a%?}

```

Try it online!
> 1 votes

# Answer
# Python3, 91 bytes

```
for _ in range(26):print(f'{" ".join([*map(chr,range(65,91))][0:_+1][::-1]):^52}'.rstrip())

```

Try it online!

*-1 byte thanks to @cairdcoinheringaahing*
> 1 votes

# Answer
# Pyth, 20 bytes

```
VlGp*dt-lGNjdr_<GhN1

```

Pretty happy with this, since it's my first Pyth answer. Probably can be golfed a lot

# Explanation

```
VlG   for N in range(26)

p*dt-lGN    26-N spaces outputted

    <GhN   First N alphabet characters
   _       Reversed
  r        Capitalised
j       1  Joined with spaces (space after each character)

```

Try it online!
> 1 votes

# Answer
# Red, 76 bytes

```
a:""repeat n 26[insert a rejoin[sp#"@"+ n]print next pad/left copy a n + 26]

```

Try it online!
> 1 votes

# Answer
# Icon, 84 bytes

```
procedure main()
s:="";i:=1to 26&s[1:1]:=" "||char(64+i)&write(right(s,25+i))&\z
end

```

Try it online!
> 1 votes

# Answer
## Python 3, 78 bytes

```
for i in range(26):print(' '*(25-i)+' '.join(chr(65+i-j) for j in range(i+1)))

```

A straightforward solution.
> 1 votes

# Answer
# Perl 6, 33 bytes

```
{(' 'Xx(25...0))Z~[\R,] 'A'..'Z'}

```

Try it online!

Anonymous code block that returns a list of lines.

### Explanation:

```
{                               }  # Anonymous code block
  ' 'Xx                            # String multiply spaces
       (25...0)                       # by the range 25 to 0
 (             )Z~                 # Zip these indents with
                  [\  ]               # The triangular reduced
                    R,                # Reversed list concatenation
                        'A'..'Z'      # Of the alphabet

```
> 1 votes

# Answer
# Keg ~~32~~ ~~31~~ ~~30~~ ~~26~~ ~~25~~ ~~24~~ 25 bytes (SBCS)

```
A(\≤|:Z$- ⅍*,:Aɧ∑, ,)⑨
,)

```

Try it online!

Hey, Keg's coming 9th (at the time of writing)! Contains unprintable characters. Uses the 26 byte approach but uses a space converted to a string to pad lines.

## Answer History

### 25 bytes

```
A(|:Aɧ ⅍!3--*,∑, ,)1+
,

```

Try it online!

### 26 bytes (SBCS)

```
A(|:Aɧ(!;;-| ,)∑, ,)1+
,

```

-4 bytes by using stack mechanics rather than the register

**Explained**

```
A(␚|:Aɧ(␚!;;-| ,)∑, ,)1+¶,
A                           #Push "A" onto the stack
(␚|                         #26 times:
    :Aɧ                     #   Push a generated range from A to the top of stack
    (␚!;;-| ,)              #   Space-align the row
    ∑, ,)                   #   Print each character space seperated
    1+                      #   Increment the top letter by one
    ¶,                      #   Print a newline

```

Substitute  for the actual unprintable control key and  for a literal newline

### 30 bytes (SBCS)

```
A&(|A&:&ɧ(!;-| ,)(, ,)&1+&
,

```

**Explained**

```
A&(␚|A&:&ɧ(␚!;-| ,)(, ,)&1+&¶,
A&                              #Put A in the register
  (␚|                           #26 times:
      A&:&ɧ                     #   Push a generated range from A to the top of stack
           (␚!;-| ,)            #   Space-align the row
                    (, ,)       #   Print each character space seperated
                         &1+&   #   Increment the top letter by one
                             ¶, #   Print a newline

```

Substitute  for the actual unprintable control key and  for a literal newline

### 31 bytes (SBCS)

```
A&(\≤|A&:&ɧ(\≤!-| ,)(, ,)&1+&
,

```

**Explained**

```
A&(\≤|A&:&ɧ(\≤!-| ,)(, ,)&1+&¶,)
A&                              #Store A in the register
  (\≤|                          #26 times:
      A&:&ɧ                     #   Push a generated range from A to the top
           (\≤!-| ,)            #   Align it using spaces
                    (, ,)       #   Print the row
                         &1+&   #   Increment the letter
                             ¶,)#   Print a newline (replace ¶ w/ \n)

```
> 1 votes

# Answer
# C# (Visual C# Interactive Compiler), 81 bytes

```
var x="A";for(char y='\x41';++y<92;x=y+" "+x){WriteLine(new string(' ',91-y)+x);}

```

Try it online!
> 1 votes

# Answer
# , 65 bytes

```
for(i in 1:26){cat(strrep(" ",26-i));cat(LETTERS[i:1]);cat("\n")}

```

Try it online!
> 1 votes

# Answer
# , 31 bytes

```
(|.@;:inv,~' '#~26-#)\u:65+i.26

```

Try it online!
> 1 votes

# Answer
# Julia 1.0, 51 bytes

```
[' '^i*join(('Z'-i:-1:'B').*' ')*'A' for i=25:-1:0]

```

Try it online!
> 1 votes

# Answer
# APL (Dyalog Extended), 22 bytes

```
(⌽0,⍳25)⌽⌽↑{∊⍺' '⍵}\⎕A

```

Try it online!

Output of above function.

Explanation:

* `⎕A` is the uppercase alphabet character vector.
* `{∊⍺' '⍵}` is a 1 character shorter version of `{⍺,' ',⍵}` which puts a space between arguments  and .
* Reducing `/` this function over `⎕A` would result in the uppercase alphabet with spaces between, `'A B C ...'`. Scanning `\` instead produces a nested vector of all the intermediate results, `('A') ('A B') ('A B C')...`.
* Mix  turns the nested vector into a matrix, padding rows to equal length with spaces, which is then horizontally mirrored with  (the one on the right).
* To get the final answer we need to rotate the rows (dyadic ) by 25, 24, 23, ... 0 characters.
* The left argument to the rotation is the sequence 25, 24, 23, ... 0, which is obtained concisely by `⌽0,⍳25`.
> 1 votes

# Answer
# Batch, 144 bytes

Abuses token delimiters (`[` and `;`)

```
@!! 2>nul||cmd/q/v/c%0&&exit/b
set;=for /l %%A in (65 1 90)do set[=
%;% ![!
%;%![:~,-1!&cmd/cexit %%A&set]=!=exitcodeascii! !]!&echo(![!!]:~,-1!

```

---

Sources

>
> 1 votes

# Answer
# Deadfish~, 10394 bytes

```
{i}{i}{i}ii{c}{c}ccccc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}{c}cccc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}{c}ccc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}{c}cc{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}{c}c{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}{c}{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}ccccccccc{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}cccccccc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}ccccccc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}cccccc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}ccccc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}cccc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}ccc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}cc{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}c{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}ii{c}{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iiccccccccc{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iicccccccc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iiccccccc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iicccccc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iiccccc{{i}ddddd}iiic{{d}iiiii}dddc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iicccc{{i}ddddd}iiiic{{d}iiiii}ddddc{{i}ddddd}iiic{{d}iiiii}dddc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iiccc{{i}ddddd}iiiiic{{d}iiiii}dddddc{{i}ddddd}iiiic{{d}iiiii}ddddc{{i}ddddd}iiic{{d}iiiii}dddc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iicc{{i}ddddd}iiiiiic{{d}iiiii}ddddddc{{i}ddddd}iiiiic{{d}iiiii}dddddc{{i}ddddd}iiiic{{d}iiiii}ddddc{{i}ddddd}iiic{{d}iiiii}dddc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{i}{i}iic{{i}dddd}dddc{{d}iiii}iiic{{i}ddddd}iiiiiic{{d}iiiii}ddddddc{{i}ddddd}iiiiic{{d}iiiii}dddddc{{i}ddddd}iiiic{{d}iiiii}ddddc{{i}ddddd}iiic{{d}iiiii}dddc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic{{d}iiiii}dddddc{{i}dd}c{{d}iiii}iic{{i}dddd}dddc{{d}iiii}iiic{{i}ddddd}iiiiiic{{d}iiiii}ddddddc{{i}ddddd}iiiiic{{d}iiiii}dddddc{{i}ddddd}iiiic{{d}iiiii}ddddc{{i}ddddd}iiic{{d}iiiii}dddc{{i}ddddd}iic{{d}iiiii}ddc{{i}ddddd}ic{{d}iiiii}dc{{i}ddddd}c{{d}iiiii}c{{i}ddddd}dc{{d}iiiii}ic{{i}ddddd}ddc{{d}iiiii}iic{{i}ddddd}dddc{{d}iiiii}iiic{{i}dddddd}iiiiiic{{d}iiiiii}ddddddc{{i}dddddd}iiiiic{{d}iiiiii}dddddc{{i}dddddd}iiiic{{d}iiiiii}ddddc{{i}dddddd}iiic{{d}iiiiii}dddc{{i}dddddd}iic{{d}iiiiii}ddc{{i}dddddd}ic{{d}iiiiii}dc{{i}dddddd}c{{d}iiiiii}c{{i}dddddd}dc{{d}iiiiii}ic{{i}dddddd}ddc{{d}iiiiii}iic{{i}dddddd}dddc{{d}iiiiii}iiic{i}{i}{i}iiiiiic{d}{d}{d}ddddddc{i}{i}{i}iiiiic{d}{d}{d}dddddc{i}{i}{i}iiiic{d}{d}{d}ddddc{i}{i}{i}iiic

```

Compared to others, terrible!
> 1 votes

# Answer
# , 52 bytes

```
write(intToUtf8(outer(26:1,1:26,"<=")*90:65,T),1,26)

```

Try it online!

A different and (for now) golfier approach than this or that R answers.

To generate "exact text" as is required in challenges, there are usually two options in R: `cat` and `write`. `cat` is more flexible, as `write` is actually a wrapper around `cat`, but the advantage of `write` is that if you can construct your data in a rectangular (matrix) form, some of the verbosity of `cat` goes away, for instance, you get a newline without explicitly including it as you do in `cat`, which will then include an extra `sep`arator argument, which is usually undesirable. Since each line of the text here appears to be of variable width, `write` is not the first thing that comes to mind, and both of the other R answers are quite creative in getting around the shortcomings of `cat`. In particular, the `fill` argument is not one I'm familiar with, but will have to keep trying out.

The trick here is that `write`, like `cat`, separates elements by spaces. Since every line has the same number of spaces, if we can construct the right matrix of empty strings `""` and capital letters, we can just use `write` to automatically put the spaces where they go.

My first attempt started by constructing the matrix directly:

# , 63 bytes

```
m=matrix(LETTERS,26,26);m[lower.tri(m)]="";write(m[26:1,],1,26)

```

Try it online!

This builds up a matrix of capital letters, then sets the lower triangle to empty strings, and finally flips vertically since `write` proceeds down the columns.

This is equally as long as Bart-Jan van Rossum's answer; I was going to post it since the approach was different, but when I went to read a comment on another completely unrelated challenge, I thought to try `intToUtf8` instead.

Two things make this possible. Typically, `intToUtf8` takes a vector of integers and converts them to a single string made up of their utf8 codepoints. There is also an optional argument, usually `FALSE` that when set to `TRUE` will instead return a vector of characters of the utf8 codepoints. The other trick is that `intToUtf8(0)` returns the empty string. So instead of constructing a matrix of `""` and `LETTERS`, I constructed a matrix of codepoints, which ended up (finally) being shorter than the other R answers:

# , 61 bytes

```
write(intToUtf8((outer(1:26,1:26,"<=")*65:90)[26:1,],T),1,26)

```

Try it online!

Luckily, despite `intToUtf8` returning a `vector`, `write` takes a `ncolumns` argument to specify how many columns wide it ought to be, which provides enough structure for `write` to print it correctly.

Finally, there are a couple of inefficient golfs which bring it to its current 52 byte form.
> 1 votes

# Answer
# Vyxal `j`, 10 bytes

```
kA¦RvṄøĊøR

```

Try it Online!

Very nice

## Explained (old)

```
₄ƛkAẎṘṄ
₄ƛ        # over the range [1, 26]: (call each item n)
  kAẎ     #     push "ABCDE....XYZ"[0:n]
     ṘṄ   #     reverse and join on spaces
          # the -C flag auto-centers the top of the stack

```
> 1 votes

# Answer
# Brainfuck, 189 bytes

`++[[+<]>+>++]<->>+[+[<]>>+<+]>>>-[-[-<]>>+<]>-<++++++++++<<<<<<<<[-[->+>+<<]>[-<+>]>[->>>>>>>.<<<<<<<]>>[->+>+<<]<+[->>>+<<<<+<+>>]<[->>>>-.>>>.<<<<<<<]<[->>+<<]>>>>>[-]<[-<+>]>>>.<<<<<<<<]`

Try It Online!

(Using 8-bit wrapping)

I cannot put into words how much I hate this language.
> 1 votes

# Answer
# Jelly, 16 bytes

```
L26_⁶x;KU$
ØAÇƤY

```

Try it online!

This seems too long for Jelly, despite being terrible at challenges
> 0 votes

# Answer
## Haskell, 63 bytes

```
[(' '<$[c..'Y'])++foldl(\s->(:' ':s))"A"['B'..c]|c<-['A'..'Z']]

```

Try it online!
> 0 votes

# Answer
# Japt, 29 bytes

```
;1o27@Bt0X)w)ò1)qS)ùS25+X})qR

```

Try it online!
> 0 votes

# Answer
# PHP, 59 bytes

```
for($a=A;$i++<26;)echo str_pad('',26-$i),$s=$a++." $s","
";

```

Try it online!
> 0 votes

# Answer
# Elixir, 70 bytes

```
r=90..65;for i<-0..25,do: IO.puts for j<-r,do: 65+i-j>-1&&[j,' ']||' '

```

Try it here
> 0 votes

# Answer
# Wren, ~~125~~ 119 bytes

Not very interesting until I read other answers.

```
for(i in 0..25){
System.write(" "*(25-i))
for(j in 0..i)System.write(" "+String.fromCodePoint(65+i-j))
System.print()
}

```

Try it online!
> 0 votes

# Answer
## Javascript ES6, 105 bytes

```
[..."ZYXWVUTSRQPONMLKJIHGFEDCBA"].forEach((l,i,a)=>console.log(" ".repeat(25-i)+a.slice(25-i).join(" ")))
```
> 0 votes

# Answer
# sed 4.2.2 (with GNU exec extension), 58 bytes

```
s/^/bash -c 'echo {Z..A}'/e
:
s/^( *)\S([^\n]+)/\1\2\n&/
t

```

Try it online!

---

# Pure sed 4.2.2, 71 bytes

```
s/^/ZYXWVUTSRQPONMLKJIHGFEDCBA/
s/\B/ /g
:
s/^( *)\S([^\n]+)/\1\2\n&/
t

```

Try it online!
> 0 votes

# Answer
# Python 3, ~~133~~ ~~130~~ ~~125~~ ~~123~~ 122 bytes

Not the shortest, but I wanted to try to make the output one single string

```
print('\n'.join((25-len(v)//2)*' '+v for v in(''.join(" "+chr(i)for i in range(90,64,-1))[i:52]for i in range(51,-1,-2))))

```

Try it online!
> 0 votes

# Answer
# Perl 5, 30 bytes

```
$b[26+--$i]=$_,say"@b"for A..Z

```

Try it online!
> 0 votes

# Answer
# Jelly, 12 bytes

```
ØAa⁶ḊÐƤżKƤUY

```

A full program which prints the result

**Try it online!**

### How?

```
ØAa⁶ḊÐƤżKƤUY - Main Link: no arguments
ØA           - (set left to) uppercase alphabet  say:['A','B','C']
   ⁶         - space character                       ' '
  a          - AND (vectorises)                      [' ',' ',' ',]
     ÐƤ      - for postfixes:
    Ḋ        -   dequeue                             [[' ',' '],[' '],[]]
         Ƥ   - for prefixes (of left=alphabet):
        K    -   join with spaces                    [['A'],['A',' ','B'],['A',' ','B',' ','C']]
       ż     - zip together                          [[[' ',' '],['A']],[[' '],['A',' ','B']],[[],['A',' ','B',' ','C']]]
          U  - upend                                 [[[' ',' '],['A']],[[' '],['B',' ','A']],[[],['C',' ','B',' ','A']]]
           Y - join with newlines                    [[' ',' '],['A'],'\n',[' '],['B',' ','A'],'\n',[],['C',' ','B',' ','A']]
             - implicit, smashing print >>>  A
             -                          >>> B A
             -                          >>>C B A

```
> 0 votes

# Answer
# C, ~~83~~ 82 bytes

(−1 golfing thanks to ceilingcat)

```
main(c){for(char s[99]="",*t=s+98;*--t=c+64,printf("%*s\n",c+++25,t)<52;*--t=32);}

```

Builds the final string from end to beginning, printing all the unfinished versions.
> 0 votes

# Answer
# Stax, 11 bytes

```
ùivK‼9⌂m¬╚─

```

Run and debug it
> 0 votes

# Answer
# Python 3.8 (pre-release), 103 bytes

```
p=-1
x="abcdefghijklmnopqrstuvwxyz"
s=""
for a in[0]*26:print(" "*abs(26-p)+" ".join(s:=x[(p:=p+1)]+s))

```

Try it online!
> 0 votes

# Answer
# Japt `-R`, 13 bytes

```
;Båi Ë¬¸ùBÊ+E

```

Test it

```
;Båi Ë¬¸ùBÊ+E
;B                :Uppercase alphabet
  å               :Cumulatively reduce by
   i              :  Prepending
     Ë            :Map each element at 0-based index E
      ¬           :  Split
       ¸          :  Join with spaces
        ù         :  Left pad with spaces to length
         BÊ+E     :    Length of B plus E

```
> 0 votes

# Answer
# Pip `-l`, 22 bytes

```
sX26-_.(RAZ@<_Js)M\,26

```

Attempt This Online!

### Explanation

```
sX26-_.(RAZ@<_Js)M\,26
                  \,26  ; Range of numbers from 1 through 26
                 M      ; Map this function to each:
  26-_                  ;  26 minus function argument
sX                      ;  That many spaces
      .(        )       ;  Concatenate to the following:
         AZ             ;  Uppercase alphabet
           @<_          ;  Slice left of function argument
        R               ;  Reverse
              Js        ;  Join on spaces

```
> 0 votes

# Answer
# Pip, 21 bytes

```
L26PsX25-i.:RAZ@<UiJs

```

Attempt This Online!

### Explanation

The guts are very similar to my Pip `-l` answer, but the iterative flagless approach turned out to be one byte shorter (at least until I implement that "center and pad with spaces" operator I've been planning).

```
L26PsX25-i.:RAZ@<UiJs
                      ; s is " ", i is 0, AZ is uppercase alphabet (implicit)
L26                   ; Loop 26 times:
    sX25-i            ;  String of (25-i) spaces
          .:          ;  Concatenate with:
                 Ui   ;   Increment i
             AZ@<     ;   Take that many characters from the front of AZ
            R         ;   Reverse
                   Js ;   Join on spaces
   P                  ;  Print that string

```
> 0 votes

---
Tags: code-golf, kolmogorov-complexity, alphabet
---


title: Make a Word Icicle

text:
# Question
Title: Make a Word Icicle
*Due to technical limitations of Stack Exchange, the title is rendered incorrectly. The **correct** title for this challenge is*

Make a

```
Word Icicle!
Word Icicle
Word  cicle
 ord  cicle
 ord   icle
 ord   i le
 or    i le
 or    i l
 or      l
 or
  r

```

---

Today's challenge is to make icicles out of the input word. Given a string of entirely printable ASCII, and at least 2 non-space characters, perform the following steps:

1. Print the current state of the string.
2. Replace the lexically smallest character (other than spaces) with a space. If there is a tie, replace the leftmost character.
3. Repeat on consecutive lines until the string contains only 1 non-space character.

This creates the effect that the input string looks like it's melting...

```
I'm Melting!!!
I'm Melting !!
I'm Melting  !
I'm Melting
I m Melting
  m Melting
  m  elting
  m   lting
  m   ltin
  m   lt n
  m    t n
       t n
       t

```

### Rules

* After a couple iterations, your output will almost surely have trailing spaces on each line. If you choose to truncate these, that is allowed.
* You may have **one** trailing empty line, but not more.
* Remember that the input may contain several spaces, but these are all effectively skipped. For example, the input `a a` should give

```
a      a
       a

```
* You may take input as a list of strings if you want. For output, you may return or print a list of strings, a single string with newlines, or char matrix/2D array. Generally, I prefer permissive IO formats, so other formats are most likely allowed as long as they are consistent and clearly correspond to the right output. If in doubt, feel free to ask. As usual, full programs or functions are allowed.
* Remember, this is a contest to make the shortest answer in any language! If you choose to answer in Java, try to make the shortest Java answer (in bytes) that you can.

### Test cases

```
Hello World! -->

Hello World!
Hello World
 ello World
 ello  orld
 ello  orl
  llo  orl
   lo  orl
    o  orl
    o  or
       or
        r

AbCdEfGhIjKlMnOpQrStUvWxYz -->

AbCdEfGhIjKlMnOpQrStUvWxYz
 bCdEfGhIjKlMnOpQrStUvWxYz
 b dEfGhIjKlMnOpQrStUvWxYz
 b d fGhIjKlMnOpQrStUvWxYz
 b d f hIjKlMnOpQrStUvWxYz
 b d f h jKlMnOpQrStUvWxYz
 b d f h j lMnOpQrStUvWxYz
 b d f h j l nOpQrStUvWxYz
 b d f h j l n pQrStUvWxYz
 b d f h j l n p rStUvWxYz
 b d f h j l n p r tUvWxYz
 b d f h j l n p r t vWxYz
 b d f h j l n p r t v xYz
 b d f h j l n p r t v x z
   d f h j l n p r t v x z
     f h j l n p r t v x z
       h j l n p r t v x z
         j l n p r t v x z
           l n p r t v x z
             n p r t v x z
               p r t v x z
                 r t v x z
                   t v x z
                     v x z
                       x z
                         z

PPCG is da BEST -->

PPCG is da BEST
PPCG is da  EST
PP G is da  EST
PP G is da   ST
PP   is da   ST
 P   is da   ST
     is da   ST
     is da    T
     is da
     is d
     is
      s

({({})({}[()])}{}) -->

({({})({}[()])}{})
 {({})({}[()])}{})
 { {})({}[()])}{})
 { {}) {}[()])}{})
 { {}) {}[ )])}{})
 { {}  {}[ )])}{})
 { {}  {}[  ])}{})
 { {}  {}[  ] }{})
 { {}  {}[  ] }{}
 { {}  {}   ] }{}
 { {}  {}     }{}
   {}  {}     }{}
    }  {}     }{}
    }   }     }{}
    }   }     } }
        }     } }
              } }
                }

```

# Answer
# Retina, 28 bytes

```
/\S/+¶<~(O`.
0L$`\S
0`$\$&¶

```

Try it online!Explanation:

```
/\S/+

```

Repeat while the input value isn't blank.

```
¶<

```

Print the current value.

```
~(

```

Execute the rest of the script on the value. Then, execute the result of that script as a script on the value.

```
O`.

```

Sort the characters into order.

```
0L$`\S
0`$\$&¶

```

Select the first nonblank character and output a Retina program that replaces the first literal (`$\`) occurrence of that character (`$&`) with a space (trailing space in original code).
> 9 votes

# Answer
# Python 2, ~~71~~ 70 bytes

-1 byte thanks to ovs

```
x=input()
while x.strip():print x;r=x.replace;x=r(min(r(*' ~')),' ',1)

```

Try it online!
> 8 votes

# Answer
# APL (Dyalog Unicode), ~~18~~ 11 bytes

```
∪∘↓∘⍉⍋∘⍋⍴⌸⊢

```

Try it online!

uses `⎕io←1`; returns an array of strings (vector of character vectors)
> 6 votes

# Answer
# 05AB1E, 9 bytes

```
ðм{v=yð.;

```

Try it online!

### Explanation

```
ð      # Push space
м      # Implicit input. Remove spaces
{      # Sort. Gives string of sorted, non-space chars
v      # For each char in that string
  =    #   Print latest string, without popping. The first time it prints the input
  y    #   Push current char
  ð    #   Push space
  .;   #   Replace first occurrence of current char by space
       # Implicitly end for-each loop

```
> 6 votes

# Answer
# Pyth, ~~17~~ ~~14~~ 13 bytes

```
V-SQdQ=XQxQNd

```

Try it here

```
V-SQdQ=XQxQNd
V-SQd              For each non-space character in the sorted input (Q)...
     Q             ... print the current value of Q...
      = Q          ... and set Q to itself...
         xQN       ... with the first instance of the character...
       X    d      ... replaced by a space.

```
> 5 votes

# Answer
# Ruby, ~~60~~ ~~58~~ ~~55~~ 47 bytes

```
->a{[-a]+a.scan(/\S/).sort.map{|x|a[x]=' ';-a}}

```

Try it online!
> 5 votes

# Answer
# sed `-rn`, 142 ~~143~~ bytes

```
:a
p
s/$/	ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s	\w+$	!"#$%\&'()*+,-./0123456789:;<=>?@&[\\]^_`\L&{|}~
:b
/(.).*	\1/!s/	./	/
tb
s/(.)(.*)	\1.*/ \2/
ta

```

Try it online!

(note: there are tabs in the program)

Since sed has no concept of lexicographical order, I had to hardcode the set of printable ASCII characters in and it takes up more than half the bytecount.

Using sed 4.2.2 will reduce bytecount by 2, since that allows for unnamed labels, Try it online!

---

`-r` enables extended regular expressions (golfier)

`-n` disables implicit printing of the pattern space at the end of the program

The pattern space starts with the input

`:a` label `a`, this is the main program loop

`p` print the pattern space (fancy name for the buffer)

now we append the set of printable ASCII characters (excluding the space)

`s/$/ ABCDEFGHIJKLMNOPQRSTUVWXYZ/` append a tab, acting as the 1-byte delimiter, followed by the uppercase alphabet

`s<tab>` substitute (sed can take any character as the delimiter, in this case the tab is used to save a byte from escaping the `/`)

* `\w+$` the uppercase alphabet we just appended
* `<tab>` with
* `!"#$%\&'()*+,-./0123456789:;<=>?@&[\\]^_\`\L&{|}~<tab>` the rest of the characters, note that `\L&` is the lowercase version of the uppercase alphabet

`:b` label `b`, remove characters from the beginning set that are not present in input

`/(.).* \1/!` if the first character from the ASCII set is not in the input

* `s/ ./ /` remove it

`tb` repeat `b` until the substitution fails

`s/(.)(.*) \1.*/ \2/` replace the first character in the ASCII set present in the input with a space, and remove the ASCII set

`ta` recurse
> 5 votes

# Answer
# , ~~140~~ 100 bytes

-40 bytes Thanks to Giuseppe !

```
function(x)for(i in any((z=utf8ToInt(x))<33):max(y<-rank(z,,"f"))){z[y==i]=32
cat(intToUtf8(z),"
")}

```

Try it online!

A solution using `outer` and Giuseppe's magic to work properly is longer at 104 bytes. Inspired by this answer.

```
function(x,z=utf8ToInt(x)-32)apply(t(outer(rank(z,,"f"),(2-(min(z)>0)):nchar(x),">=")*z+32),1,intToUtf8)

```

Try it online!
> 4 votes

# Answer
# Python 3, 71 bytes

```
f=lambda a:[*a.strip()]and[a]+f(a.replace(min(a.replace(*" ~"))," ",1))

```

Try it online!

-4 bytes thanks to ovs
> 3 votes

# Answer
# K (ngn/k), ~~26~~ 24 bytes

```
{?(,x),x{x[y]:" ";x}\<x}

```

Try it online!
> 3 votes

# Answer
# Python 2, ~~70~~ ~~69~~ ~~66~~ 64 bytes

```
def f(s):print s;S=set(s)-{' '};S and f(s.replace(min(S),' ',1))

```

Try it online!

Thx for 2 bytes from ovs via using `S and f()` instead of `if S:f()`
> 3 votes

# Answer
# Perl 5 `-n`, ~~37~~ 34 bytes

*Dropped three bytes with help from @TonHospel*

```
say&&s/\Q$a/ / while($a)=sort/\S/g

```

Try it online!
> 3 votes

# Answer
# JavaScript, ~~67~~ ~~66~~ 65 bytes

Because I haven't golfed drunk in a while!

```
s=>[...t=s].sort().map(x=>x>` `?t+=`
${s=s.replace(x,` `)}`:0)&&t

```

Try it online

Thanks to DanielIndie for pointing out 4 redundant bytes that beer included!
> 3 votes

# Answer
# Jelly, 8 bytes

```
ẋ"ỤỤ$z⁶Q

```

Try it online!

### Idea

The basic idea is to build the columns of the desired output directly, instead of manipulating the string and returning all intermediate results.

We start by numerating the characters of the input string in the order they will be removed. For the moment, we'll pretend spaces will be removed as well.

```
tee ay oh
845139276

```

Now, we build the columns by repeating each character by its index in this enumeration.

```
tee ay oh
tee ay oh
tee ay oh
tee  y oh
t e  y oh
t    y oh
t    y o
t    y
     y

```

All that's left is to remove duplicates, to account for the spaces.

### Code

```
ẋ"ỤỤ$z⁶Q  Main link. Argument: s (string)

    $     Combine the two links to the left into a chain.
  Ụ       Grade up; sort the indices of s by their corresponding values.
          Let's call the result J.
          Grade up again, sorting the indices of J by the corr. values in J.
          This enumerates the positions of s as described before.
ẋ"        Repeat each character of s that many times.
     z⁶   Zip the resulting 2D array, filling missing characters with spaces.
       Q  Unique; deduplicate the array of rows.

```
> 3 votes

# Answer
# JavaScript (Node.js), ~~80~~ 65 bytes

```
x=>[...x].sort().map(c=>x=x.replace(c,' ',c>' '&&console.log(x)))

```

Try it online!

Didn't know `replace` take string as string, not regexp
> 2 votes

# Answer
## Perl 5 with `-nlF/\s|/`, 39 bytes

```
@F=sort@F;say,s~\Q$F[$F++]~ ~ while/\S/

```

This might be pushing the boundaries of Perl's flags not being counted, if so I'll revert to the previous answer.

Try it online!
> 2 votes

# Answer
# gcc 32-bit, ~~66~~ 65 bytes

```
char*p,i;f(a){for(i=32;i++;)for(p=a;*p;)*p==i?puts(a),*p=32:++p;}
main(){char s[]="3.1415926";f(s);}

```

Thanks for Jonathan Frech for -1 byte
> 2 votes

# Answer
# C# (Visual C# Interactive Compiler), 129 bytes

```
var s=ReadLine();while(s.Any(c=>c!=32)){WriteLine(s);var i=s.IndexOf(s.Min(c=>c==32?(char)999:c));s=s.Remove(i,1).Insert(i," ");}

```

Try it online!
> 2 votes

# Answer
# , 27 bytes

```
>>ò2Ùúú^lDhrfDj|@"r kdòdj<H

```

Try it online!

Hexdump:

```
00000000: 3e3e f232 d9fa fa5e 6c44 6872 6644 6a7c  >>.2...^lDhrfDj|
00000010: 4022 7220 6b64 f264 6a3c 48              @"r kd.dj<H

```
> 2 votes

# Answer
# Haskell, 67 bytes

*12 bytes saved thanks to Laikoni*

```
f s|(a,_:b)<-span(/=minimum(id=<<words s))s=putStrLn s>>f(a++' ':b)

```

Try it online!

*This one terminates in an error*

# Haskell, ~~83~~ 79 bytes

```
g(a,_:b)=a++' ':b
mapM_ putStrLn.(iterate$g.(span=<<(/=).minimum.concat.words))

```

Try it online!

*This one terminates in an error*

# Haskell, 86 bytes

```
u=concat.words
g(a,_:b)=a++' ':b
(take.length.u)<*>(iterate$g.(span=<<(/=).minimum.u))

```

Try it online!

# Haskell, ~~100~~ ~~91~~ 88 bytes

```
u=concat.words
f x|(a,_:b)<-span(/=minimum(u x))x=a++' ':b
(take.length.u)<*>(iterate f)

```

Try it online!
> 2 votes

# Answer
# K4, ~~28~~ ~~20~~ 18 bytes

**Solution:**

```
?x{x[y]:" ";x}\<x:

```

**Example:**

```
q)k)?x{x[y]:" ";x}\<x:"PPCG is da BEST"
"PPCG is da BEST"
"PPCG is da  EST"
"PP G is da  EST"
"PP G is da   ST"
"PP   is da   ST"
" P   is da   ST"
"     is da   ST"
"     is da    T"
"     is da     "
"     is d      "
"     is        "
"      s        "
"               "

```

**Explanation:**

It's the same thing as ngn is doing. Find indices that would result in an ascending list, overwrite them one-by-one with `" "`, then take the distinct to remove any duplicate lines:

```
?x{x[y]:" ";x}\<x: / the solution
                x: / save input as x
               <   / return indices that would result in ascending sort
 x{        ; }\    / two-line lambda with scan
        " "        / whitespace
       :           / assignment
   x[y]            / x at index y
            x      / return x
?                  / distinct

```
> 2 votes

# Answer
# Common Lisp, ~~240~~ ~~228~~ 224 bytes

```
(setf s(read))(defun f(x)(setf y(char-code(elt s x)))(if(= y 32)1e9 y))(loop for _ across s do(print s)do(setf s(replace s" ":start1(position(code-char(reduce #'min (loop for i from 0 below(length s)collect i):key #'f))s))))

```

Try it online!

This is my first time posting.
I'm in the process of learning lisp so I'm sure someone can think of something shorter than this.
> 2 votes

# Answer
# MATLAB, 74 bytes

This uses the 2-output form of the max() function to retrieve the smallest character and its index, having transformed the string to zero values in the spaces and 256-the character value for the printable characters.

```
s=input('s');x=1;while(x);disp(s);[x,y]=max((256-s).*(s~=' '));s(y)=' ';end

```
> 2 votes

# Answer
# APL (Dyalog Unicode), 39 bytesSBCS

```
{⎕←⍵⋄×≢⍵∩g←' '~⍨⎕UCS⍳256:∇' '@(⊃g⍋⍵)⊢⍵}

```

Try it online!

Dfn.

### How?

```
{⎕←⍵⋄×≢⍵∩g←' '~⍨⎕UCS⍳256:∇' '@(⊃g⍋⍵)⊢⍵} ⍝ Main function, argument ⍵
 ⎕←⍵⋄                                    ⍝ Print ⍵
         g←' '~⍨⎕UCS⍳256                 ⍝ Assign to g every Unicode character except space
     ×≢⍵∩                :               ⍝ If ⍵∩g is not empty
                          ∇              ⍝ Recursively call the function with argument:
                           ' '@       ⍵  ⍝ Space at
                               (⊃g⍋⍵)    ⍝ The first (⊃) element in ⍵ graded up (⍋) with g
                                         ⍝ The dyadic grade up function will index ⍵ according
                                         ⍝ to its left argument, in this case g.

```
> 1 votes

# Answer
# PowerShell, ~~103~~ 99 bytes

```
param($a)2..$a.length|%{($x=$a);[regex]$p=""+([char[]]$a-ne' '|sort)[0];$a=($p.replace($x," ", 1))}

```

Try it online!

Takes input as a string into `$a`. We then loop from `2` to `$a.length` (i.e., the appropriate number of vertical times necessary to remove all but one character). Each iteration, we output the current string and conveniently saved into `$x` at the same time. We then construct a new `[regex]` object, `$p`attern consisting of the remaining characters in `$a` that are `-n`ot`e`qual to space, `sort`ed, then the `0`th one thereof.

We then set `$a` equal to a new string of the regex object with the `.Replace` method to replace in the string `$x`, the `$p`attern, with a space `" "`, but only the `1`st match. Yeah, this syntax is weird.

The strings are left on the pipeline and implicit `Write-Output` gives us a newline between them for free, plus one trailing newline.
> 1 votes

# Answer
# Perl 6, ~~42~~ 37 bytes

```
{$_,{S/$(.comb(/\S/).min)/ /}...*eq*}

```

Try it online!
> 1 votes

# Answer
# Java (JDK 10), 140 bytes

```
s->{for(int m=1,i;m>0;s=s.substring(0,i=s.indexOf(m=s.chars().filter(c->c>32).min().orElse(0)))+" "+s.substring(i+1))System.out.println(s);}

```

Try it online!

Technically there's a blank line, but it's not *empty*.
> 1 votes

# Answer
# Japt, ~~32~~ 18 bytes

*Saved 14 bytes thanks to Shaggy!*

```
rS ¬£=hSUbZn gYÃiN

```

Try it online!
> 1 votes

# Answer
# MATL, ~~17~~ 16 bytes

```
tSXz"tOy@=f1)(]x

```

Try it online! Or verify all test cases.

### Explanation

```
t       % Implicit input. Duplicate
S       % Sort
Xz      % Remove spaces
"       % For each char in that string
  t     %   Duplicate last result. This is the most recent string obtained
        %   from replacing chars by spaces in the input
  O     %   Push 0
  y     %   Duplicate from below
  @     %   Push current char
  =     %   Equals? (element-wise) Gives 1 for occurrences of current char
        %   in the most recent string, 0 otherwise
  f     %   Indices of nonzeros
  1)    %   Get the first entry
  (     %   Write 0 at that position. Char 0 will be displayed as space
]       % End
x       % Delete last result, which consists only of space / char zero

```
> 1 votes

# Answer
# Stax, 9 bytes

```
ü¡%/"=πbΓ

```

Run and debug it

This is the same algorithm as Luis' 05AB1E solution
> 1 votes

# Answer
# Excel VBA, 167 bytes

An anonymous VBE immediate window function that takes input from range `[A1]` and outputs to the VBE immediate window.

```
s="Code(Mid(A$1,Row(),1))":[B1].Resize([Len(A1)])="=If("&s &"=32,1E3,"&s &")":For i=1To[Len(A1)-CountIf(B:B,1E3)]:?[A1]:[A1]=[Substitute(A1,Char(Min(B:B))," ",1)]:Next

```

# Ungolfed and Commented

```
''  run as `call icicle("Test")` or `icicle"I am the WALRUS`
Sub icicle(Optional str As String)
    If Not IsMissing(str) Then [A1] = str   ''  pipe input
    [B:B].Clear                             ''  reset between runs
    [B1].Resize([Len(A1)]) = "=If(Code(Mid(A$1,Row(),1))=32,1E3,Code(Mid(A$1,Row(),1)))"  ''  get char number for every char in input
    For i = 1 To [Len(A1)-CountIf(B:B,1E3)] ''  iterate across from 1 to length of input - number of spaces
        Debug.Print [A1]                    ''  output a single line
        [A1]=[Substitute(A1,Char(Min(B:B))," ",1)]  ''  replace minimum char with space
    Next
End Sub

```
> 1 votes

# Answer
# Z80 machine code on an Amstrad CPC, 51 bytes, 54 with safety

The following code progressively destroys the input string as each line is output:

```
(1A B7 C8)EB 4E 23 5E 23 56 41 1A 13 CD 5A BB 10
 F9 26 FF 41 1B 1A FE 21 38 06 BC 30 03 68 67 24
 10 F2 24 C8 2D 26 00 19 36 20 3E 0D CD 5A BB 3E
 0A CD 5A BB 18 D3

```

As assembler:

WinAPE Z80 Assembler V1.0.13

```
000001  0000  (8000)        ORG &8000
000002  8000  1A            LD A, (DE)
000003  8001  B7            OR A
000004  8002  C8            RET Z
000006  8003  EB            EX DE, HL
000008  8004  4E            LD C, (HL)
000010  8005  23            INC HL
000011  8006  5E            LD E, (HL)
000012  8007  23            INC HL
000013  8008  56            LD D, (HL)
000015  8009                LabelPrintString
000016  8009  41            LD B, C
000017  800A                LabelPrintChar
000018  800A  1A            LD A, (DE)
000019  800B  13            INC DE
000020  800C  CD 5A BB      CALL &BB5A
000021  800F  10 F9         DJNZ LabelPrintChar
000023  8011  26 FF         LD H, &FF
000024  8013  41            LD B, C
000026  8014                LableIcicle
000027  8014  1B            DEC DE
000028  8015  1A            LD A, (DE)
000029  8016  FE 21         CP &21
000030  8018  38 06         JR C, LabelNextChar
000031  801A  BC            CP H
000032  801B  30 03         JR NC, LabelNextChar
000033  801D  68            LD L, B
000034  801E  67            LD H, A
000035  801F  24            INC H
000036  8020                LabelNextChar
000037  8020  10 F2         DJNZ LableIcicle
000038  8022  24            INC H
000039  8023  C8            RET Z
000040  8024  2D            DEC L
000041  8025  26 00         LD H, &00
000042  8027  19            ADD HL, DE
000043  8028  36 20         LD (HL), &20
000044  802A  3E 0D         LD A, &0D
000045  802C  CD 5A BB      CALL &BB5A
000046  802F  3E 0A         LD A, &0A
000047  8031  CD 5A BB      CALL &BB5A
000048  8034  18 D3         JR LabelPrintString

```

# Z80 machine code on an Amstrad CPC, 63 bytes, 66 with safety

I reworked the code to be non-destructive, but unfortunately the best I could do increased the size by 12 bytes:

```
(1A B7 C8)EB 46 23 5E 23 56 26 20 24 C8 2E 00 D5
 C5 0E 00 1A BC 38 0A 20 0A 0C 79 BD 38 03 1A 18
 02 3E 20 2C 2D 28 03 CD 5A BB 13 10 E6 28 0A 3E
 0D CD 5A BB 3E 0A CD 5A BB 7D B9 C1 D1 30 CC 2C
 18 CD

```

As assembler:

```
000001  0000  (8000)        ORG &8000
000002  8000                LabelSafeEntry
000003  8000                ; On entry, DE contains pointer to last parameter
000004  8000  1A            LD A, (DE)
000005  8001  B7            OR A
000006  8002  C8            RET Z ; Return if the input string had zero length
000008  8003                ; Start here if safety not required
000009  8003                LabelUnsafeEntry
000010  8003  EB            EX DE, HL ; HL is easier to use than DE. Swap their values
000012  8004                ; First byte is length of string
000013  8004  46            LD B, (HL)
000015  8005                ; Next word is address of string. Load it into DE
000016  8005  23            INC HL
000017  8006  5E            LD E, (HL)
000018  8007  23            INC HL
000019  8008  56            LD D, (HL)
000021  8009  26 20         LD H, &20 ; current_char
000023  800B                LabelNextChar
000024  800B  24            INC H
000025  800C  C8            RET Z
000026  800D  2E 00         LD L, &00 ; number
000028  800F                LabelParseString
000029  800F  D5            PUSH DE
000030  8010  C5            PUSH BC
000032  8011  0E 00         LD C, &00 ; number2
000033  8013                LabelPrintString
000034  8013  1A            LD A, (DE)
000035  8014  BC            CP H
000036  8015  38 0A         JR C, LabelPrintSpace
000037  8017  20 0A         JR NZ, LabelPrintChar
000038  8019  0C            INC C
000039  801A  79            LD A, C
000040  801B  BD            CP L
000041  801C  38 03         JR C, LabelPrintSpace
000042  801E  1A            LD A, (DE)
000043  801F  18 02         JR LabelPrintChar
000044  8021                LabelPrintSpace
000045  8021  3E 20         LD A, &20
000046  8023                LabelPrintChar
000047  8023  2C            INC L
000048  8024  2D            DEC L
000049  8025  28 03         JR Z, LabelSkipPrint
000050  8027  CD 5A BB      CALL &BB5A
000051  802A                LabelSkipPrint
000052  802A  13            INC DE
000053  802B  10 E6         DJNZ LabelPrintString
000055  802D  28 0A         JR Z, LabelNoNewLine
000056  802F  3E 0D         LD A, &0D
000057  8031  CD 5A BB      CALL &BB5A
000058  8034  3E 0A         LD A, &0A
000059  8036  CD 5A BB      CALL &BB5A
000060  8039                LabelNoNewLine
000061  8039  7D            LD A, L
000062  803A  B9            CP C
000063  803B  C1            POP BC
000064  803C  D1            POP DE
000065  803D  30 CC         JR NC, LabelNextChar
000066  803F  2C            INC L
000067  8040  18 CD         JR LabelParseString

```
* The first 3 optional bytes check if the string is empty. Since the challenge specified a string of at least two characters, I'm not counting these bytes and starting execution with `CALL &8003, a$` instead of `CALL &8000, a$`
* The next 6 bytes get the input string into a usable state. A pointer to a reference to the last parameter (the string) is passed to the program in `DE`. The pointer can be used directly, but the reference needs to be dereferenced

## Program 1

* `8009` \- `8035` **Print String**
    + Load counter register `B` with string length `C`
    + Do **Print Char** (on exit `B` is `&00` and `DE` is the string address + its length)
    + Load `H` with `&FF` \- an invalid ASCII character
    + Load counter register `B` with string length `C`
    + Do **Icicle** (on exit `B` is `&00`, `H` is the next ASCII character after the one to be replaced (if found), `L` is the character position to change to a space, and `DE` is back to just the string address)
    + Increment `H`. If it was still `&FF`, it will wrap to `&00`
    + Return if zero (this is the only exit point)
    + Decrement `L` to make it zero-based
    + Load `H` with `&00`. This expands the 8-bit value in `L` to a 16-bit value in `HL`
    + Add `DE` to `HL` (this is the address of the character to change)
    + Load the memory at `(HL)` with a space
    + Print "\r" (5 bytes of code!)
    + Print "\n" (another 5 bytes of code!)
    + Repeat **Print String**
* `800A` \- `8010` **Print Char** (works the string left-to-right)
    + Load `A` with the current character pointed to by `(DE)`
    + Increment `DE`
    + Do a system call to print the character in `A`
    + Decrement `B` and repeat **Print Char** if not zero
* `8014` \- `8021` **Icicle** (works the string right-to-left)
    + Decrement `DE`
    + Load `A` with the current character pointed to by `(DE)`
    + If `A` is less than `&21`, go to the end of the loop
    + If `A` is greater than or equal to `H`, go to the end of the loop
    + Store the current character position (`B`) in `L`
    + Store the current ASCII character in `H`
    + Increment `H` so that repeats of this character can be detected easily
    + Decrement `B` and repeat **Icicle** if not zero

The last line always contains only spaces.

## Program 2

See annotations in the code. The last line always contains one printing character other than spaces.

The programs are called from BASIC by either passing a string variable or a string literal.

* `CALL &8003, a$`
* `CALL &8003, "I'm Melting!!!"`
> 1 votes

# Answer
# Oracle SQL 11.2, 196 bytes

```
WITH v(s)AS(SELECT :1 FROM DUAL UNION ALL SELECT REGEXP_REPLACE(s,(SELECT MIN(TRIM(SUBSTR(s,LEVEL,1)))FROM DUAL CONNECT BY LEVEL<=LENGTH(s)),' ',1,1)FROM v WHERE LENGTH(TRIM(s))>0)SELECT * FROM v;

```

Un-golfed

```
WITH v(s)AS
(
  SELECT :1 FROM DUAL
  UNION ALL
  SELECT REGEXP_REPLACE(s,(SELECT MIN(TRIM(SUBSTR(s,LEVEL,1)))
                           FROM DUAL CONNECT BY LEVEL<=LENGTH(s)),' ',1,1)
  FROM v WHERE LENGTH(TRIM(s))>0
)
SELECT * FROM v;

```
> 1 votes

# Answer
# Pyth, 13 bytes

```
uXGxG<r6S
G1d

```

Try it here!

A nice challenge I wanted to answer for a long time. I am aware that there's another Pyth 13-byter, but the methods used to solve the task are quite different, so I think it's worth posting (this one doesn't use imperative structures like `V` nor assignments such as `=`). The output contains obnoxiously many unnecessary trailing spaces and linefeeds.

### Explanation

It's a full program that takes input from STDIN (quoted) and outputs to STDOUT.

```
uXGxG<r6S\nG1d – Note that I escaped the newline using \n, for readability.

u              – Until a result that has occurred before is found, do the following:
         \nG   – Print the current state of the string, G, which is initially the input.
        S      – Sort the current string.
      r6       – Strip all whitespace.
     <      1  – Take the first element, but avoid throwing errors if there are no
                 characters left to be trimmed.
   xG          – Find its index in G.
 XG          d – And replace the character at the index with a space.

```
> 1 votes

# Answer
# ,  ~~36~~  32 bytes

```
echo~.(\:\:~"1]\@\:~)&.|.>2{ARGV

```

previous 36 = `echo~.@|.@(|.@/:/:~"1[:]\\:~)>2{ARGV` .. my silly redundant `@`'s wasted 2 chars NB. improvements courtesy of @FrownyFrog

explanation:

* `> 2{ ARGV` unboxes the second argument of TIO's script runner
* `&. |.` reverse string do … and re-reverse the result
* `( \: \:~"1 ]\@\:~ )` permutes each row (i.e. columns)
* `\:` permutation required to rank descending `\:~` sort descending
* `echo ~.` print the distinct (aka "nub") rows

or if the text has a space as its least char, 24 bytes fn

```
f=:/:~{~i.@#(]*<)"{/:@/:

```

TIO
> 1 votes

# Answer
## brainfuck, 125 bytes

```
,[.[>+>+<<-]>>>++++[<-------->-],]<,<[[<<<]>>>[[>[-[>]->[>>]<<<+[>,<+++[>+++++++
+<-]>[<<<]>>>[.>>>]+[-<+]]]>]>]<<<[<<[>>]<]<]

```

Formatted:

```
,
[
  .[>+>+<<-]
  >>>++++[<-------->-],
]
<,<
[
  [<<<]
  >>>
  [
    [
      >
      [
        -[>]
        ->[>>]
        <<<+
        [
          >,<+++[>++++++++<-]>[<<<]
          >>>[.>>>]
          +[-<+]
        ]
      ]
      >
    ]
    >
  ]
  <<<
  [
    <<[>>]
    <
  ]
  <
]

```

Expects a trailing newline in the input.

Try it online
> 1 votes

# Answer
# Attache, 45 bytes

```
PeriodicSteps!{Place[_,_&Index!Min!_^^sp,sp]}

```

Try it online!

## Explanation

`PeriodicSteps` takes a function `f` as an argument and returns a function which nests `f` on the argument until two results are the same. Then, all intermediate results are stored in a list and returned.

Then, `{Place[_,_&Index!Min!_^^sp,sp]}` performs a single "metling" iteration:

```
{Place[_,_&Index!Min!_^^sp,sp]}
{                             }   anonymous function
 Place[                    sp]    place a space
           Index!Min!_              where the index of of the minimal element
                      ^^sp            (except spaces)
       _,_&                       ...in the input

```
> 1 votes

# Answer
# Powershell, 92 bytes

```
param($s)($s|% t*y)-ne' '|sort|%{$c=$_;$s
$s=-join($s|% t*y|%{if(!($c-$_)){$c=($_=' ')}$_})}

```

Less golfed test script:

```
$f = {

param($s)                   # an argument string
($s|% t*y)-ne' '|sort|%{    # convert toCharArray(), exclude ' ', sort and make for each char...
    $s                      # push current string to the pipe as a line of the result
    $c=$_                   # store current char
    $s=-join($s|% t*y|%{    # $s is a new copy
        if(!($c-$_)){       # in which a first occurence of the current char and spaces
            $c=($_=' ')     # replaced by space char
        }
        $_                  # push a char to new $s
    })
}

}

@(

    ,("TD.([)]* a) regex specials",   # ;P
      "TD.([)]* a) regex specials",
      "TD. [)]* a) regex specials",
      "TD. [ ]* a) regex specials",
      "TD. [ ]* a  regex specials",
      "TD. [ ]  a  regex specials",
      "TD  [ ]  a  regex specials",
      "T   [ ]  a  regex specials",
      "    [ ]  a  regex specials",
      "      ]  a  regex specials",
      "         a  regex specials",
      "            regex specials",
      "            regex speci ls",
      "            regex spe i ls",
      "            r gex spe i ls",
      "            r g x spe i ls",
      "            r g x sp  i ls",
      "            r   x sp  i ls",
      "            r   x sp    ls",
      "            r   x sp     s",
      "            r   x s      s",
      "                x s      s",
      "                x        s",
      "                x         ")

    ,("Word Icicle!",
      "Word Icicle!",
      "Word Icicle ",
      "Word  cicle ",
      " ord  cicle ",
      " ord   icle ",
      " ord   i le ",
      " or    i le ",
      " or    i l  ",
      " or      l  ",
      " or         ",
      "  r         ")

     ,("I'm Melting!!!",
       "I'm Melting!!!",
       "I'm Melting !!",
       "I'm Melting  !",
       "I'm Melting   ",
       "I m Melting   ",
       "  m Melting   ",
       "  m  elting   ",
       "  m   lting   ",
       "  m   ltin    ",
       "  m   lt n    ",
       "  m    t n    ",
       "       t n    ",
       "       t      ")

     ,("Hello World!",
       "Hello World!",
       "Hello World ",
       " ello World ",
       " ello  orld ",
       " ello  orl  ",
       "  llo  orl  ",
       "   lo  orl  ",
       "    o  orl  ",
       "    o  or   ",
       "       or   ",
       "        r   ")

    ,("AbCdEfGhIjKlMnOpQrStUvWxYz",
      "AbCdEfGhIjKlMnOpQrStUvWxYz",
      " bCdEfGhIjKlMnOpQrStUvWxYz",
      " b dEfGhIjKlMnOpQrStUvWxYz",
      " b d fGhIjKlMnOpQrStUvWxYz",
      " b d f hIjKlMnOpQrStUvWxYz",
      " b d f h jKlMnOpQrStUvWxYz",
      " b d f h j lMnOpQrStUvWxYz",
      " b d f h j l nOpQrStUvWxYz",
      " b d f h j l n pQrStUvWxYz",
      " b d f h j l n p rStUvWxYz",
      " b d f h j l n p r tUvWxYz",
      " b d f h j l n p r t vWxYz",
      " b d f h j l n p r t v xYz",
      " b d f h j l n p r t v x z",
      "   d f h j l n p r t v x z",
      "     f h j l n p r t v x z",
      "       h j l n p r t v x z",
      "         j l n p r t v x z",
      "           l n p r t v x z",
      "             n p r t v x z",
      "               p r t v x z",
      "                 r t v x z",
      "                   t v x z",
      "                     v x z",
      "                       x z",
      "                         z")

    ,("PPCG is da BEST",
      "PPCG is da BEST",
      "PPCG is da  EST",
      "PP G is da  EST",
      "PP G is da   ST",
      "PP   is da   ST",
      " P   is da   ST",
      "     is da   ST",
      "     is da    T",
      "     is da     ",
      "     is d      ",
      "     is        ",
      "      s        ")

    ,("({({})({}[()])}{})",
      "({({})({}[()])}{})",
      " {({})({}[()])}{})",
      " { {})({}[()])}{})",
      " { {}) {}[()])}{})",
      " { {}) {}[ )])}{})",
      " { {}  {}[ )])}{})",
      " { {}  {}[  ])}{})",
      " { {}  {}[  ] }{})",
      " { {}  {}[  ] }{} ",
      " { {}  {}   ] }{} ",
      " { {}  {}     }{} ",
      "   {}  {}     }{} ",
      "    }  {}     }{} ",
      "    }   }     }{} ",
      "    }   }     } } ",
      "        }     } } ",
      "              } } ",
      "                } ")

) | % {
    $s,$expected = $_
    $result = &$f $s
    "$result"-eq"$expected"
    $result            # comment this line to compact output
}

```

Output:

```
True
TD.([)]* a) regex specials
TD. [)]* a) regex specials
TD. [ ]* a) regex specials
TD. [ ]* a  regex specials
TD. [ ]  a  regex specials
TD  [ ]  a  regex specials
T   [ ]  a  regex specials
    [ ]  a  regex specials
      ]  a  regex specials
         a  regex specials
            regex specials
            regex speci ls
            regex spe i ls
            r gex spe i ls
            r g x spe i ls
            r g x sp  i ls
            r   x sp  i ls
            r   x sp    ls
            r   x sp     s
            r   x s      s
                x s      s
                x        s
                x
True
Word Icicle!
Word Icicle
Word  cicle
 ord  cicle
 ord   icle
 ord   i le
 or    i le
 or    i l
 or      l
 or
  r
True
I'm Melting!!!
I'm Melting !!
I'm Melting  !
I'm Melting
I m Melting
  m Melting
  m  elting
  m   lting
  m   ltin
  m   lt n
  m    t n
       t n
       t
True
Hello World!
Hello World
 ello World
 ello  orld
 ello  orl
  llo  orl
   lo  orl
    o  orl
    o  or
       or
        r
True
AbCdEfGhIjKlMnOpQrStUvWxYz
 bCdEfGhIjKlMnOpQrStUvWxYz
 b dEfGhIjKlMnOpQrStUvWxYz
 b d fGhIjKlMnOpQrStUvWxYz
 b d f hIjKlMnOpQrStUvWxYz
 b d f h jKlMnOpQrStUvWxYz
 b d f h j lMnOpQrStUvWxYz
 b d f h j l nOpQrStUvWxYz
 b d f h j l n pQrStUvWxYz
 b d f h j l n p rStUvWxYz
 b d f h j l n p r tUvWxYz
 b d f h j l n p r t vWxYz
 b d f h j l n p r t v xYz
 b d f h j l n p r t v x z
   d f h j l n p r t v x z
     f h j l n p r t v x z
       h j l n p r t v x z
         j l n p r t v x z
           l n p r t v x z
             n p r t v x z
               p r t v x z
                 r t v x z
                   t v x z
                     v x z
                       x z
                         z
True
PPCG is da BEST
PPCG is da  EST
PP G is da  EST
PP G is da   ST
PP   is da   ST
 P   is da   ST
     is da   ST
     is da    T
     is da
     is d
     is
      s
True
({({})({}[()])}{})
 {({})({}[()])}{})
 { {})({}[()])}{})
 { {}) {}[()])}{})
 { {}) {}[ )])}{})
 { {}  {}[ )])}{})
 { {}  {}[  ])}{})
 { {}  {}[  ] }{})
 { {}  {}[  ] }{}
 { {}  {}   ] }{}
 { {}  {}     }{}
   {}  {}     }{}
    }  {}     }{}
    }   }     }{}
    }   }     } }
        }     } }
              } }
                }

```
> 1 votes

# Answer
# Japt `-R`, 14 bytes

```
·cU¸c¬Í£=hSUbX

```

Try it

```
·cU¸c¬Í£=hSUbX     :Implicit input of string U
·                  :Split on newlines (of which there are none)
 c                 :Concatenate
  U¸               :  Split U on spaces
    c              :  Flat map
     ¬             :    Split
      Í            :  Sort
       £           :  Map each X
        =          :    Reassign to U
         h         :      Replace character in U at index
           UbX     :      First index of X in U
          S        :      with Space

```

## 12 bytes

If only we didn't have to handle inputs containing RegEx characters.

```
¸c¬Íi £=rXSP

```

Try it
> 1 votes

# Answer
# Uiua SBCS, 9 bytes

```
⍉⬚@ ∵▽⍏⍏.

```

Try it!

```
⍉⬚@ ∵▽⍏⍏.
        .  # duplicate
      ⍏⍏   # double rise ie the index of each character's sorted position
 ⬚@ ∵▽     # repeat each letter that many times, filling with space
⍉          # transpose

```
> 1 votes

# Answer
# Vyxal `j`, 7 bytes

```
ȧgḟðȦ)↔

```

Try it Online! Outputs as a list of lines, `j` flag formats as string.

```
     )↔ # Repeat until no change, collecting intermediates
  ḟ     # Find the index of
 g      # Minimum
ȧ       # (ignoring spaces)
    Ȧ   # Replace the char at that index with
   ð    # A space

```
> 1 votes

# Answer
## Retina, 40 bytes

```
/\S/{¶<`^
$'¶
O`\G.
 *(\S).*¶(.*?)\1
$2

```

Try it online!
> 0 votes

# Answer
# Haskell, 107 bytes

```
f s|sum[1|' '<-s]+1==length s=[s]|g<-(/=minimum(filter(/=' ')s))=s:f(fst(span g s)++' ':tail(snd$span g s))

```

Try it online!

Just out-golf me. Shouldn't be too hard, my brain isn't fully functional right now. :P
> 0 votes

# Answer
# Julia 0.6, 82 bytes

```
g(s,r=filter(c->c!=' ',s),q=println(s))=isempty(r)||g(replace(s,minimum(r),' ',1))

```

Try it online!
> 0 votes

# Answer
# Charcoal, 22 bytes

```
ＷΦθ‹ κ«θ⸿≔⭆θ⎇⁼λ⌕θ⌊ι κθ

```

Try it online! Link is to verbose verison of code. Explanation:

```
ＷΦθ‹ κ«

```

Filter out spaces from the value. Repeat while there are still characters remaining, which are saved in the variable `i`, as we'll need the smallest later, and we don't want to include spaces in that determination. (There used to be a bug in Charcoal whereby the `while` loop didn't reserve the variable `i` until after the first loop, which would have made the `Filter` impossible, as the first loop it would try to use `i` instead of `k`.)

```
θ⸿

```

Print the value on its own line.

```
≔⭆θ⎇⁼λ⌕θ⌊ι κθ

```

Map over the characters of the value, replacing the one at the same position as the lexically smallest with a space, and replace the value with the result.
> 0 votes

# Answer
# Python 3, 93 bytes

```
a=input()
while len(a)-a.count(' '):print(a);a=a.replace(sorted(a.replace(' ',""))[0],' ',1)

```

EDIT: Python 3, +1 -\> remembered that python 2's input is int
> 0 votes

# Answer
# Coconut, 46 bytes

```
x->scan((o,n)->o.replace(n,' ',1),sorted(x),x)

```

Try it online!
> 0 votes

---
Tags: code-golf, string, ascii-art
---


title: Mapping Passing Through Point

text:
# Question
Title: Mapping Passing Through Point
(Inspired by this challenge.)

Given six real values in three pairs: \\$(x\_1, x\_2), (y\_1, y\_2),\\$ and \\$(x\_0, y\_0)\\$, where \\$x\_1 \< x\_0 \< x\_2\\$ and \\$y\_1 \< y\_0 \< y\_2\\$, create a function which maps between \\$(x\_1, x\_2)\\$ and \\$(y\_1, y\_2)\\$ which also passes through \\$(x\_0,y\_0)\\$. In other words, make some function

$$f: \mathbb{R} \to \mathbb{R},\\; f((x\_1, x\_2)) = (y\_1, y\_2),\\; f(x\_0) = y\_0$$

Note that the image of the function has to be over the whole interval -- in other words, for every \\$y \in (y\_1,y\_2)\\$, there must be some \\$x \in (x\_1,x\_2)\\$, such that \\$f(x)=y\\$.

* *The function does not need to be bijective.*
* The value of the function cannot be outside of the given \\$y\\$ range.

For example, for \\$(x\_1, x\_2) = (0, 10), (y\_1, y\_2) = (0, 10), x\_0 = 4, y\_0 = 2\\$, a possible function is

$$\begin{cases} \frac12 x & 0 \< x \leq 4 \\ -\frac43 x + \frac{46}{3} & 4 \< x \< 10 \end{cases}$$

Which looks like:

On the edge points (i.e. when \\$x = x\_1\\$ or \\$x = x\_2\\$) or outside of the interval, the function can have whatever value you want, or it can be undefined.

---

*Note: You don't have to return a function -- you could also write your code so that it takes in \\$x\_1, x\_2, y\_1, y\_2, x\_0, y\_0, x\\$ and returns \\$y = f(x)\\$ following the constraints above.*

Standard loopholes are forbidden. Since this is , the shortest function wins.

# Answer
> 9 votes
# , 6 bytes

```
approx

```

Try it online! or Try it with graphical output at rdrr.io

Input is `x1,x2,x0`, `y1,y2,y0`, `x`; output is `x,y`.

This seems like a fairly straightforward task for which built-in solution ought to exist in , and indeed it does.

---

# , ~~48~~ 38 bytes

```
\(a,b,c,x)(a+(x*(b+c-2*a)/c[1])%%b)[2]

```

Attempt This Online! or Try it with graphical output at rdrr.io

Input is `x1,y1`, `x2,y2`, `x0,y0`, `x`; output is `y`.

Non-builtin solution. Avoids any kind of curve-fitting tomfoolery by using a deliberately non-bijective function.

# Answer
> 4 votes
# MATL, 4 bytes

```
&1Yn

```

The implemented mapping consists of two straight segments: the first from the point \\$(x\_1,y\_1)\\$ to \\$(x\_0,y\_0)\\$, and the second from \\$(x\_0,y\_0)\\$ to \\$(x\_2,y\_2)\\$.

The code inputs two numerical vectors and a number: `[x1 x0 x2]`, `[y1 y0 y2]`, `x`. Then it simply calls the `interp1` function, which linearly interpolates the data defined by `[x1 x0 x2]` and `[y1 y0 y2]` at the abscissa `x`. The ouput is the value `y` corresponding to `x`.

**Try it online!** You can also see the graph of the mapping **here**.

# Answer
> 3 votes
# JavaScript (ES6), 71 bytes

Expects \\$(x\_0,x\_1,x\_2,y\_0,y\_1,y\_2,x)\\$.

Just uses quadratic interpolation, which is most certainly not the shortest approach.

```
(a,b,c,d,e,f,x)=>(x-b)*((f-e)/(c-b)-(e-=d)/(b-=a))/(c-a)*(x-=a)+e/b*x+d

```

Try it online!

# Answer
> 3 votes
# Charcoal, 31 bytes

```
ＮθＮηＮζＦ⊕›θη«ＮεＮδ»Ｉ⁺ζ∕×⁻θη⁻δζ⁻εη

```

Try it online! Link is to verbose version of code. Takes input as seven numbers `x`, `x₀`, `y₀`, `x₁`, `y₁`, `x₂` and `y₂`. Explanation: Performs linear interpolation between `x₀` and `y₀` and either `x₁` and `y₁` or `x₂` and `y₂` depending on whether `x` is greater than `x₀` or not.

```
Ｎθ

```

Input `x`.

```
ＮηＮζ

```

Input `x₀` and `y₀`.

```
Ｆ⊕›θη«ＮεＮδ»

```

Input `x₁` and `y₁` or `x₂` and `y₂` depending on whether `x` is greater than `x₀`.

```
Ｉ⁺ζ∕×⁻θη⁻δζ⁻εη

```

Perform linear interpolation.

# Answer
> 3 votes
# Pyt, 33 bytes

```
Đ←=?ĉ←:←ŕŕ←←-Đ↔⇹ᵮ₄%⇹/4*←Đ←⇹-⇹↔*+;

```

Try it online!

Uses \\$f(x)=\left\\{\begin{array}{ c l }y\_0 &\quad\textrm{if }x=x\_0 \\y\_1+(y\_2-y\_1)\*{4\left(x\\!\\!\\!\\!\mod\\!{x\_2-x\_1\over 4}\right)\over x\_2-x\_1}& \quad\textrm{otherwise}\end{array}\right. \\$

Takes input as the following, each on a new line: `x x0 y0 x2 x1 y1 y2`

| Code | Stack | Action |
| --- | --- | --- |
| Đ | \\$x\ x\\$ | implicit input; `Đ`uplicate |
|  | \\$x\ x\ x\_0\\$ | get \\$x\_0\\$ |
| =? | \\$x\ \\{x\\!=\\!x\_0\\}\\$ | if \\$x=x\_0\\$: |
| ĉ← | \\$y\_0\\$ | `ĉ`lear the stack and get \\$y\_0\\$ |
| :←ŕŕ | \\$x\\$ | otherwise, get \\$y\_0\\$ and then `ŕ`emove \\$\\{x\\!=\\!x\_0\\}\\$ and \\$y\_0\\$ |
| ←←- | \\$x\ z\\$ | get \\$x\_2\\$ and \\$x\_1\\$ and then subtract (call it \\$z\\$) |
| Đ | \\$x\ z\ z\\$ | `Đ`uplicate |
| ↔⇹ | \\$z\ x\ z\\$ | manipulate the stack |
| ᵮ₄ | \\$z\ x\ {z\over4}\\$ | cast to loat, then divide by 4 |
| % | \\$z\ q\\$ | \\$x\\!\\!\\!\\!\mod\\!\\! {z\over4}\\$ (call it \\$q\\$) |
|  | \\$q\ z\\$ | swap top two items on stack |
| / | \\${q\over z}\\$ | divide |
| 4\* | \\${4q\over z}\\$ | multiply by 4 |
| ←Đ | \\${4q\over z}\ y\_1\ y\_1\\$ | get \\$y\_1\\$ and `Đ`uplicate |
|  | \\${4q\over z}\ y\_1\ y\_1\ y\_2\\$ | get \\$y\_2\\$ |
| ⇹- | \\${4q\over z}\ y\_1\ m\\$ | swap top two on stack and then subtract (call it \\$m\\$) |
| ⇹↔ | \\$y\_1\ m\ {4q\over z}\\$ | manipulate the stack |
| * | \\$y\_1\ {4mq\over z}\\$ | multiply |
| + | \\$y\_1+{4mq\over z}\\$ | add |
| ; |  | either way, implicit print |

The function is onto \\$(y\_1,y\_2)\\$ as follows:

It can be trivially shown that if the discontinuity at \\$x\_0\\$ did not exist, then \\$\forall y\in(y\_1,y\_2)\\$, \\$\exists\\$ at least one \\$x\in(x\_1,x\_2)\\$ s.t. \\$f(x)=y\\$. In fact, there would be between two and four such points for all values.

Some of you may object here and say that \\$\nexists x\in(x\_1,x\_2)\\$ s.t. \\$f(x)=y\_2\\$, and you'd be right. However, the problem lists the intervals as open, and so the endpoints are not necessary.

Since without the discontinuity, there would be at least two distinct \\$x\in(x\_1,x\_2)\\$ such that \\$f(x)=y\\$, with the discontinuity, every point must have at least one such \\$x\\$. Therefore, \\$f(x)\\$ is onto \\$(y\_1,y\_2)\\$.

# Answer
> 2 votes
# Python, 81 bytes

```
lambda a,b,c,d,e,f,x:(x-b)*((f-e)/(c-b)-(e:=e-d)/(b:=b-a))/(c-a)*(x:=x-a)+e/b*x+d

```

Attempt This Online!

Port of Arnauld's JS answer.

# Answer
> 0 votes
# JavaScript (Node.js), 55 bytes

```
f=(p,a,b,x,y,c,d)=>p>x?f(p,x,y,c,d):(y-b)/(x-a)*(p-a)+b

```

Try it online!

The linear map must be not shortest

Two segments

---
Tags: code-golf, open-ended-function
---