Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 296679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:34:14+00:00 2026-05-12T06:34:14+00:00

For some game where one would need to find anagrams from a bunch of

  • 0

For some game where one would need to find anagrams from a bunch of loose letters I ended up implementing a permutation algorithm to find all possible anagrams and filter those if needed for known letter positions (-match is great, by the way). But for longer words this proved very much error-prone, as skimming a large list of gibberish doesn’t really reveal the proper words that were hidden within.

So I thought that if I would have a large list of English words (should be obtainable somewhere) I could just intersect my list of permutations with the list of proper words and get (hopefully) all real words from the permutation list.

Since many operators in PS work differently with collections I thought I could just do something like

$wordlist -contains $permlist

and get the intersection back. Unfortunately it’s not that easy. Other options I have thought of would be to iterate over one list and do a -contains for each item:

$permlist | ? { $wordlist -contains $_ }

This probably would work but is also very slow, I think (especially when $wordlist is the result of a gc wordlist.txt). Or I could build a gigantic regular expression:

$wordlist -matches (($permlist | %{ "^$_`$" }) -join "|")

But that would probably not be very fast either. I could maybe also use findstr with above gigantic regex but that feels just wrong.

Are there any built-in solutions I could use and that are better than my attempts so far? Otherwise I’d probably put the word list into a hashtable and use the iterative -contains approach which should be fast enough then.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:34:15+00:00Added an answer on May 12, 2026 at 6:34 am
    $left = New-HashSet string
    $left.Add("foo")
    $left.Add("bar")
    $right = New-HashSet string
    $right.Add("bar")
    $right.Add("baz")
    
    $left.IntersectWith($right)
    $left.UnionWith($right)
    

    (borrowing New-HashSet from Josh Einstein)

    Warning: those methods on HashSet are in-place algorithms that modify the original collection. If you want functional-style transform on immutable objects, you’ll need to bring LINQ to the party:

    add-type system.core
    
    $asqueryable = [system.linq.queryable].getmethods() | ? { $_.name -eq "AsQueryable" } | select -first 1
    $asqueryable = $asqueryable.MakeGenericMethod([string])
    $leftAsQueryable = $asqueryable.Invoke($null, (,$left))
    
    $intersect = [system.linq.queryable].getmethods() | ? { $_.name -eq "Intersect" } | select -first 1
    $intersect = $intersect.MakeGenericMethod([string])
    $result = $intersect.Invoke($null, ($leftAsQueryable, $right))
    

    Clearly, someone needs to wrap this static-generic-reflection crap into a friendly cmdlet! Don’t worry, I’m working on it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a 3D space trading game with some people, and one of
For some reason during loading one of the scenes in my game, the background
i need some advice. i have 2 classes for a game that i am
Hi i have some movieclips like this one: game_mc.substage_mc.rightHand and inside the rightHand i
I'm making some game, and I have made it pretty much all, but not
OK so I am working on some game logic, I have done a fair
I am trying to make some game, I'm not going to explain what is
I'm trying to make some kind of top for some game stadistics Table it's
I was reading some old game programming books and as some of you might
I am current making some small JS game in Netbeans and I have started

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.