Post History
APL (Dyalog Unicode), 11 7 bytes (SBCS) Razetime and rak1507 came up with 7 byte equivalents of my original dfn (this one's rak1507's). See their solutions below. +/¨⊢=,\ Try it online! +/¨...
Answer
#6: Post edited
# [APL (Dyalog Unicode)], 11 bytes- <!-- language-all: lang-apl -->
{+/¨⍵=¨,\⍵}[Try it online!][TIO-knme645v]- [APL (Dyalog Unicode)]: https://www.dyalog.com/
[TIO-knme645v]: https://tio.run/##SyzI0U2pTMzJT///P@1R24Rqbf1DKx71brU9tEInBkjX/n/UNxUorpCmYAiERmBoCIbGCsZccEljBXMFUwUTBUugtDEQmymY/QcA "APL (Dyalog Unicode) – Try It Online"- ```
{+/¨⍵=¨,\⍵},\⍵ ⍝ Prefixes of the list⍵=¨ ⍝ Compare every element to its corresponding prefix+/ ⍝ Count how many are equal in each prefix```### Also 11 bytes<!-- language-all: lang-apl -->+/⍤=¨∘(,\)⍨[Try it online!][TIO-knmedn0d][APL (Dyalog Unicode)]: https://www.dyalog.com/[TIO-knmedn0d]: https://tio.run/##SyzI0U2pTMzJT//v@KhtQvWj3l1ApKABIh71bgUiEKVZCyTnKgTk51SmZebkKKTlFwEFlvxPA2rR1ne0PbTiUccMDZ0YzUe9K/4/6psKFFZIUzAEQiMwNARDYwVjLriksYK5gqmCiYIlUNoYiM0UzP4DAA "APL (Dyalog Unicode) – Try It Online"
- # [APL (Dyalog Unicode)], <s>11</s> 7 bytes (SBCS)
- Razetime and rak1507 came up with 7 byte equivalents of my original dfn (this one's rak1507's). See their solutions below.
- <!-- language-all: lang-apl -->
- +/¨⊢=,\
- [Try it online!][TIO-knnd726n]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-knnd726n]: https://tio.run/##SyzI0U2pTMzJT///P@1R2wRt/UMrHnUtstWJ@f@obypQQCFNwRAIjcDQEAyNFYy54JLGCuYKpgomCpZAaWMgNlMw@w8A "APL (Dyalog Unicode) – Try It Online"
- ```
- +/¨⊢=,\
- ,\ ⍝ Prefixes of the list
- = ⍝ Compare every prefix
- ⊢ ⍝ to the corresponding element in the original list
- +/ ⍝ Sum each to get a count of how many elements in each prefix match
- ```
#4: Post edited
- # [APL (Dyalog Unicode)], 11 bytes
- <!-- language-all: lang-apl -->
- {+/¨⍵=¨,\⍵}
- [Try it online!][TIO-knme645v]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-knme645v]: https://tio.run/##SyzI0U2pTMzJT///P@1R24Rqbf1DKx71brU9tEInBkjX/n/UNxUorpCmYAiERmBoCIbGCsZccEljBXMFUwUTBUugtDEQmymY/QcA "APL (Dyalog Unicode) – Try It Online"
- ```
- {+/¨⍵=¨,\⍵}
- ,\⍵ ⍝ Prefixes of the list
- ⍵=¨ ⍝ Compare every element to its corresponding prefix
- +/ ⍝ Count how many are equal in each prefix
```
- # [APL (Dyalog Unicode)], 11 bytes
- <!-- language-all: lang-apl -->
- {+/¨⍵=¨,\⍵}
- [Try it online!][TIO-knme645v]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-knme645v]: https://tio.run/##SyzI0U2pTMzJT///P@1R24Rqbf1DKx71brU9tEInBkjX/n/UNxUorpCmYAiERmBoCIbGCsZccEljBXMFUwUTBUugtDEQmymY/QcA "APL (Dyalog Unicode) – Try It Online"
- ```
- {+/¨⍵=¨,\⍵}
- ,\⍵ ⍝ Prefixes of the list
- ⍵=¨ ⍝ Compare every element to its corresponding prefix
- +/ ⍝ Count how many are equal in each prefix
- ```
- ### Also 11 bytes
- <!-- language-all: lang-apl -->
- +/⍤=¨∘(,\)⍨
- [Try it online!][TIO-knmedn0d]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-knmedn0d]: https://tio.run/##SyzI0U2pTMzJT//v@KhtQvWj3l1ApKABIh71bgUiEKVZCyTnKgTk51SmZebkKKTlFwEFlvxPA2rR1ne0PbTiUccMDZ0YzUe9K/4/6psKFFZIUzAEQiMwNARDYwVjLriksYK5gqmCiYIlUNoYiM0UzP4DAA "APL (Dyalog Unicode) – Try It Online"
#3: Post edited
# [APL (Dyalog Unicode)], 12 bytes- <!-- language-all: lang-apl -->
(1 1⍉+\)∘.=⍨[Try it online!][TIO-knmbgria]- [APL (Dyalog Unicode)]: https://www.dyalog.com/
[TIO-knmbgria]: https://tio.run/##SyzI0U2pTMzJT///P@1R2wQNQwXDR72d2jGajzpm6Nk@6l0BFFcACioYgaEhGBorGHOlKRjrmOuY6pjoWOoY6RgDsZmOGQA "APL (Dyalog Unicode) – Try It Online"I'm nowhere near those brownie points, but that's fine, since I've been eating too many sweets these days.Explanation:- ```
(1 1⍉+\)∘.=⍨∘.=⍨ ⍝ Compare every element with every other element+\ ⍝ Take the cumulative sum of each row of that boolean matrix1 1⍉ ⍝ Get the diagonal of that matrix- ```
- # [APL (Dyalog Unicode)], 11 bytes
- <!-- language-all: lang-apl -->
- {+/¨⍵=¨,\⍵}
- [Try it online!][TIO-knme645v]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-knme645v]: https://tio.run/##SyzI0U2pTMzJT///P@1R24Rqbf1DKx71brU9tEInBkjX/n/UNxUorpCmYAiERmBoCIbGCsZccEljBXMFUwUTBUugtDEQmymY/QcA "APL (Dyalog Unicode) – Try It Online"
- ```
- {+/¨⍵=¨,\⍵}
- ,\⍵ ⍝ Prefixes of the list
- ⍵=¨ ⍝ Compare every element to its corresponding prefix
- +/ ⍝ Count how many are equal in each prefix
- ```
#1: Initial revision
# [APL (Dyalog Unicode)], 12 bytes <!-- language-all: lang-apl --> (1 1⍉+\)∘.=⍨ [Try it online!][TIO-knmbgria] [APL (Dyalog Unicode)]: https://www.dyalog.com/ [TIO-knmbgria]: https://tio.run/##SyzI0U2pTMzJT///P@1R2wQNQwXDR72d2jGajzpm6Nk@6l0BFFcACioYgaEhGBorGHOlKRjrmOuY6pjoWOoY6RgDsZmOGQA "APL (Dyalog Unicode) – Try It Online" I'm nowhere near those brownie points, but that's fine, since I've been eating too many sweets these days. Explanation: ``` (1 1⍉+\)∘.=⍨ ∘.=⍨ ⍝ Compare every element with every other element +\ ⍝ Take the cumulative sum of each row of that boolean matrix 1 1⍉ ⍝ Get the diagonal of that matrix ```