Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

81%
+7 −0
Challenges Is it a near-anagram?

APL (Dyalog Extended), 18 bytes Anonymous tacit prefix function taking a list of two strings as argument. 2=1⊥(≠⌿∊≢⍤⊢⌸⍤,⍤1↑) Try it online! (…) apply the following tacit function to the arg...

posted 3y ago by Adám‭

Answer
#1: Initial revision by user avatar Adám‭ · 2021-03-02T00:31:34Z (over 3 years ago)
# [APL (Dyalog Extended)], 18 bytes

<!-- language-all: lang-apl -->

Anonymous tacit prefix function taking a list of two strings as argument.

    2=1⊥(≠⌿∊≢⍤⊢⌸⍤,⍤1↑)

[Try it online!][TIO-klr9s1xj]

`(`…`)` apply the following tacit function to the argument:

&emsp;`↑` mix the list of strings into a 2-row character matrix (padding any short string with spaces as necessary)

&emsp;`∊`…`⍤1` with the **e**nlisted (flattened into a single string) argument as left argument, apply the following function to each row of the matrix:

&emsp; `⍤,` concatenate the enlisted string to the row string, then:

&emsp;  `≢⍤⊢⌸` count the number of occurrences of each unique element, in their order of appearance

&emsp;`≠⌿` Boolean mask indicating where the rows differ

`1⊥` sum (lit. evaluate as unary; i.e. count differences)

`2=` is 2 equal to that?



[APL (Dyalog Extended)]: https://github.com/abrudz/dyalog-apl-extended
[TIO-klr9s1xj]: https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/38jW8FHXUo1HnQse9ex/1NH1qHPRo94lj7oWPerZAWToALHho7aJmv/THrVNeNTb96ir@VHvmke9Ww6tNwaKP@qbGhzkDCRDPDyD/6cpqDu6@Du5qgNpJ38XV3UuoEhIaIAPSCQk1MczACzi6OTsAhJxcXRxcgaLODkGqSsogGk/mICfOkQgyNUPqgukBKwbne@iDgA "APL (Dyalog Extended) – Try It Online"