Skip to main content
added 1223 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

05AB1E, 6 bytes

.¡{}€н 

Try it online or verify all test cases.

Or alternatively:

€{DÙkè 

Try it online or verify all test cases.

Explanation:

 # EXAMPLE INPUT: ["cat","tac","dog","god","act"] .¡ } # Group the words in the (implicit) input-list by: { # Sort the characters inof the word # STACK: [["cat","tac","act"],["dog","god"]] € # Then map over each group of words: н # And only leave the first one # STACK: ["cat","dog"] # (after which the list of remaining words is output implicitly) € # Map over each word of the (implicit) input-list: { # Sort the characters of the word # STACK: ["act","act","dgo","dgo","act"] D # Duplicate this list of individually sorted words # STACK: ["act","act","dgo","dgo","act"],["act","act","dgo","dgo","act"] Ù # Uniquify the copy list of strings # STACK: ["act","act","dgo","dgo","act"],["act","dgo"] k # Pop both, and get the indices of the remaining strings # STACK: [0,2] è # Use those indices to index into the (implicit) input-list of words # STACK: ["cat","dog"] # (after which the list of remaining words is output implicitly) 

05AB1E, 6 bytes

.¡{}€н 

Try it online or verify all test cases.

Explanation:

.¡ } # Group the (implicit) input-list by: { # Sort the characters in the word € # Then map over each group of words: н # And only leave the first one # (after which the list of remaining words is output implicitly) 

05AB1E, 6 bytes

.¡{}€н 

Try it online or verify all test cases.

Or alternatively:

€{DÙkè 

Try it online or verify all test cases.

Explanation:

 # EXAMPLE INPUT: ["cat","tac","dog","god","act"] .¡ } # Group the words in the (implicit) input-list by: { # Sort the characters of the word # STACK: [["cat","tac","act"],["dog","god"]] € # Then map over each group of words: н # And only leave the first one # STACK: ["cat","dog"] # (after which the list of remaining words is output implicitly) € # Map over each word of the (implicit) input-list: { # Sort the characters of the word # STACK: ["act","act","dgo","dgo","act"] D # Duplicate this list of individually sorted words # STACK: ["act","act","dgo","dgo","act"],["act","act","dgo","dgo","act"] Ù # Uniquify the copy list of strings # STACK: ["act","act","dgo","dgo","act"],["act","dgo"] k # Pop both, and get the indices of the remaining strings # STACK: [0,2] è # Use those indices to index into the (implicit) input-list of words # STACK: ["cat","dog"] # (after which the list of remaining words is output implicitly) 
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

05AB1E, 6 bytes

.¡{}€н 

Try it online or verify all test cases.

Explanation:

.¡ } # Group the (implicit) input-list by: { # Sort the characters in the word € # Then map over each group of words: н # And only leave the first one # (after which the list of remaining words is output implicitly)