May
16
2009

US States Puzzle

Originally taken from

http://interviewpattern.com/post/Puzzles-and-Riddles-on-the-interview-(Part-e28093-I).aspx

Take the names of two U.S. States, mix them all together, then rearrange the letters to form the names of two other U.S. States.

What states are these?

using our Combinatorics library 

using System;
using System;
using System.Collections.Generic;
using System.Linq;

namespace StatePuzzle
{
internal class Program
{
    private static void Main(string[] args)
    {
        var listStates = new List
            {
            "Alabama","Alaska","AmericanSamoa","Arizona","Arkansas","California",
            "Colorado","Connecticut","Delaware","DistrictofColumbia","Florida",
            "Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa",
            "Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts",
            "Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska",
            "Nevada","NewHampshire","NewJersey","NewMexico","NewYork","NorthCarolina",
            "NorthDakota","Ohio","Oklahoma","Oregon","Pennsylvania",
            "PuertoRico","RhodeIsland","SouthCarolina","SouthDakota","Tennessee",
            "Texas","Utah","Vermont","Virginia","VirginIslands","Washington",
            "WestVirginia","Wisconsin","Wyoming"
            };

        foreach (var statePair in Combinatorics.Combinations(listStates, 2))
        {

            var chars = string.Join(string.Empty, statePair.ToArray())
                        .ToLower()
                        .ToCharArray()
                        .OrderBy(c => c);

            var toSearch = listStates.Except(statePair).ToList();

            foreach (var statePairSeach in Combinatorics.Combinations(toSearch, 2))
            {

                var charsSearch = string.Join(string.Empty, statePairSeach.ToArray())
                                .ToLower()
                                .ToCharArray()
                                .OrderBy(c => c);
                if( chars.Count() == charsSearch.Count() && 
                    chars.SequenceEqual(charsSearch))
                {
                    Console.Write("Letters that make up the States :");
                    Console.Write(string.Join(",", statePair.ToArray()));
                    Console.WriteLine("");
                    Console.Write("Can be re-arranged to read :");
                    Console.Write(string.Join(",", statePairSeach.ToArray()));
                    Console.WriteLine("");
                    Console.WriteLine("");
                }
            }
        }

        Console.ReadLine();
    }
}
}
May
11
2009

Google Latitude widget for BlogEngine.Net

I’ve created a widget that enables you to share your Google Public Location Badge directly in your BlogEngine.Net powered blog.

Just drop the contents of the attached file into the \widgets folder.

Month List