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 6592697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:35:17+00:00 2026-05-25T17:35:17+00:00

This is a small scrabble side project I was tinkering with and wanted to

  • 0

This is a small scrabble side project I was tinkering with and wanted to get some input on what I may be doing wrong. I have a “dictionary” of letters and their respective scores and a list of words. My ideas was to find the letters that were in each word and sum the scores together.

// Create a letter score lookup
var letterScores = new List<LetterScore>
                       {
                           new LetterScore {Letter = "A", Score = 1},
                           // ...
                           new LetterScore {Letter = "Z", Score = 10}
                       };

// Open word file, separate comma-delimited string of words into a string list
var words = File.OpenText("c:\\dictionary.txt").ReadToEnd().Split(',').ToList();                           

// I was hoping to write an expression what would find all letters in the word (double-letters too) 
// and sum the score for each letter to get the word score.  This is where it falls apart.
var results = from w in words
          join l in letterScores on // expects an 'equals'
          // join l in letterScores on l.Any(w => w.Contains(
          select new
                     {
                         w,
                         l.Score
                     };

Any help would be greatly appreciated.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 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-25T17:35:18+00:00Added an answer on May 25, 2026 at 5:35 pm

    You can’t, basically – Join in LINQ is always an equijoin. You can achieve the effect you want, but not with join. Here’s an example:

    var results = from w in words
                  from l in letterScores
                  where l.Any(w => w.Contains(l.Letter))
                  select new { w, l.Score };
    

    I think this is what you were trying to do with your query, although it won’t give you the word score. For the full word score, I’d build a dictionary from letter to score, like this:

    var scoreDictionary = letterScores.ToDictionary(l => l.Letter, l => l.Score);
    

    Then you can find the score for each word by summing the score for each letter:

    var results = from w in words
                  select new { Word = w, Score = w.Sum(c => scoreDictionary[c]) };
    

    Or not as a query expression:

    var results = words.Select(w => new { Word = w,
                                          Score = w.Sum(c => scoreDictionary[c]) });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this small class called City that simply holds some information about a
I have this small program that reads a line of input & prints the
I have this small project I have been working on. I have a MySQL
I have this small script: http://jsfiddle.net/gmAjC/ <input name=n1 value=test> <br/><span></span> <br/> <span style=background-color:red>after input</span>
I have this small code library that I'm considering releasing into Open Source. I
I have this small SQL query. SELECT a.`id` , a.`title` , a.`date` , (
Work on this small test application to learn threading/locking. I have the following code,
I have this small piece of code String[] words = {{apf,hum_,dkoe,12f}; for(String s:words) {
I am working on this small project where I'd like to generate the call
I have this small script: <? header('Content-Type: text/javascript; charset=utf-8'); $s=L\u00e1szl\u00f3 M\u00e1rton; echo $s; ?>

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.