14

1

In @Adám's Dyalog APL Extended, the `⍢`

(under) operator means conjugation: apply one function, then a second function, then the inverse of the first. It's fun to think of real-life actions in terms of conjugation:

A problem is transformed by g into another domain where it more readily solved by f , and then transformed back into the original domain. An example from real life is “under anesthetics”:

`apply anesthetics perform surgery wake up from anesthetics`

## Challenge

The inverse of a line `g`

is "un" prepended to `g`

, and vice versa. Define any line between `s`

and its inverse, in that order, as being "under" `s`

. For each line `f`

in input in order:

- If
`f`

and its inverse both occur, do nothing - If
`f`

is not "under" any other action, print`f`

- If
`f`

is "under" a line`g`

, print`f + " under " + g`

where`+`

is concatenation.

### Input

A nonempty multiline string, or list of strings, etc., consisting of spaces and lowercase letters (you may instead use uppercase). Exactly one line will begin with "un"; and it will be the inverse of some other line. No line will be empty.

### Output

Output in the same format you took input in, or as allowed by Standard I/O.

### Test cases:

```
Input:
apply anesthetics
perform surgery
unapply anesthetics
Output:
perform surgery under apply anesthetics
Input:
unite asia
establish the silk road
ite asia
Output:
establish the silk road under unite asia
Input:
desire a book
walk to store
take the book
pay for the book
unwalk to store
read the book
Output:
desire a book
take the book under walk to store
pay for the book under walk to store
read the book
Input:
drink excessively
undrink excessively
Output:
[empty string]
```

2I, too, have no output when I drink excessively – Stan Strum – 2018-12-01T21:06:23.380

1shouldn't it be "take the book and pay for the book under walk to store"? otherwise it's not clear that the transform is equivalent to the original... – Jonah – 2018-12-02T21:41:21.540

1@Jonah The idea is in an ideal world w="walk to store" and w^-1="unwalk to store" are inverses, so mathematically wfw^-1wg^-1 = wfgw^-1. – lirtosiast – 2018-12-02T22:33:50.840

Ah fair enough, @lirtosiast. – Jonah – 2018-12-02T23:22:36.467