예제 #1
0
파일: Program.cs 프로젝트: nickprys/repos
    static void Main(string[] args)
    {
        int     x  = 5;
        strings tr = Convert.ToString(x);

        Console.WriteLine(x);
        Concole.ReadKey();
    }
예제 #2
0
        // given a list of words and a list of anagrams, make more
        // anagrams by combining the two.
        private static anagrams combine(strings ws, anagrams ans)
        {
            anagrams rv = new anagrams();

            foreach (strings a in ans)
            {
                foreach (string word in ws)
                {
                    strings bigger_anagram = new strings();
                    bigger_anagram.InsertRange(0, a);
                    bigger_anagram.Add(word);
                    rv.Add(bigger_anagram);
                }
            }

            return(rv);
        }
예제 #3
0
        static void Main(string[] args)
        {
            strings ob = new strings();

            ob.checkString();
        }
예제 #4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            string filename = DICTIONARY_FOLDER + "/" + "quran-words.txt";

            using (StreamReader reader = File.OpenText(filename))
            {
                ResultLabel.Text    = "Compiling dictionary ...";
                ProgressBar.Minimum = 0;
                ProgressBar.Maximum = (int)reader.BaseStream.Length;
                ProgressBar.Value   = 0;
                ListView_Resize(sender, e);
                try
                {
                    String line;
                    // Read and display lines from the file until the end of the file is reached.
                    int       linesRead          = 0;
                    Hashtable stringlists_by_bag = new Hashtable();
                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.ToLower();

                        Bag aBag = new Bag(line);
                        if (!stringlists_by_bag.ContainsKey(aBag))
                        {
                            strings l = new strings();
                            l.Add(line);
                            stringlists_by_bag.Add(aBag, l);
                        }
                        else
                        {
                            strings l = (strings)stringlists_by_bag[aBag];
                            if (!l.Contains(line))
                            {
                                l.Add(line);
                            }
                        }
                        linesRead++;
                        ProgressBar.Increment((line.Length + 2) * 2);   // the +1 is for the line ending character, I'd guess.
                        // the *2 is to deal with unicode characters
                        Application.DoEvents();
                    }

                    // Now convert the hash table, which isn't useful for
                    // actually generating anagrams, into a list, which is.
                    m_dictionary = new List <bag_and_anagrams>();
                    foreach (DictionaryEntry de in stringlists_by_bag)
                    {
                        m_dictionary.Add(new bag_and_anagrams((Bag)de.Key, (strings)de.Value));
                    }
                    m_dictionary.Sort();

                    // Now just for amusement, sort the list so that the biggest bags
                    // come first.  This might make more interesting anagrams appear first.
                    bag_and_anagrams[] sort_me = new bag_and_anagrams[m_dictionary.Count];
                    m_dictionary.CopyTo(sort_me);
                    Array.Sort(sort_me);
                    m_dictionary.Clear();
                    m_dictionary.InsertRange(0, sort_me);
                }
                catch (Exception ex)
                {
                    throw new Exception("Dictionary: " + ex.Message);
                }

                ResultLabel.Text       = "Ready.";
                ListView.Enabled       = true;
                LettersTextBox.Enabled = true;
                LettersTextBox.Focus();
                TypeUniqueLettersToolStripMenuItem_Click(sender, e);
            }

            //Bag.Test();
        }
예제 #5
0
        public static anagrams anagrams(Bag bag,
                                        List <bag_and_anagrams> dictionary,
                                        uint recursion_level,
                                        bottom_of_main_loop bottom,
                                        done_pruning done_pruning_callback,
                                        found_anagram success_callback)
        {
            anagrams rv = new anagrams();
            List <bag_and_anagrams> pruned = prune(bag,
                                                   dictionary,
                                                   done_pruning_callback,
                                                   recursion_level);
            int pruned_initial_size = pruned.Count;

            while (pruned.Count > 0)
            {
                bag_and_anagrams entry = pruned[0];
                Bag this_bag           = entry.b;
                Bag diff = bag.subtract(this_bag);
                if (diff != null)
                {
                    if (diff.empty())
                    {
                        foreach (string w in entry.words)
                        {
                            strings loner = new strings();
                            loner.Add(w);
                            rv.Add(loner);
                            if (recursion_level == 0)
                            {
                                success_callback(loner);
                            }
                        }
                    }
                    else
                    {
                        anagrams from_smaller = anagrams(diff, pruned, recursion_level + 1,
                                                         bottom,
                                                         done_pruning_callback,
                                                         success_callback);
                        anagrams combined = combine(entry.words, from_smaller);
                        foreach (strings an in combined)
                        {
                            rv.Add(an);
                            if (recursion_level == 0)
                            {
                                success_callback(an);
                            }
                        }
                    }
                }
                pruned.RemoveAt(0);
                if (recursion_level == 0)
                {
                    bottom();
                }

                Application.DoEvents();
            }
            return(rv);
        }
예제 #6
0
 // *sigh* this is tediously verbose
 public bag_and_anagrams(Bag b, strings words)
 {
     this.b     = b;
     this.words = words;
 }
예제 #7
0
    public static string Value(strings pName)
    {
        switch (pName)
        {
        case strings.INFO:
            return(rus?"И - Инструкция":"I - Instructions");

            break;

        case strings.PLAY:
            return(rus?"Н - Начало игры":"S - Start game");

            break;

        case strings.INSTRUCTIONS:
            if (rus)
            {
                return(@"              О С Т Р О В   С О К Р О В И Щ
                            (С)1989 С.А.Ларионов, г.Свердловск

        Вам нужно провести Джима по извилистым тропам Острова
сокровищ,  найти  спрятанный  в  пещере клад и отнести его на 
корабль.  Остерегайтесь  встречающихся на Вашем  пути пиратов.
Некоторые  из  них  умеют  метать свои сабли и могут поразить
Вас.  Однако  при известной сноровке можно увернуться и подо-
брать упавшую на землю  саблю.  В э том случае Вы сами можете
поразить пирата, метнув саблю с помощью клавиши <ПРОБЕЛ>.
        Чтобы попасть в пещеру, Вам нужно найти спрятанный на
острове  ключ,  а чтобы выкопать сокровища, надо прихватить с
собо  лопату.  На  обратном  пути  Вы должны спастись от пре-
следований одноногого Джона Силвера.
        Удачи Вам!
                                     Нажмите <ПРОБЕЛ>
");
            }
            else
            {
                return
                    (@"TREASURE ISLAND
---------------

An exciting game based upon the classic adventure by Robert Louis Stevenson,
using the memorable screens from the original story as a backdrop for
arcade style action.

This exciting game is based upon the classic adventure by Robert Louis
Stevenson.

First Jim Hawkins must avoid Blind Pew to board the good ship Hispaniola.
Then he has to avoid capture having heard the crew's mutinous plans. Once
these challenges have been overcome the main game can be played on Treasure
Island itself.

The quest for the treasure starts at the stockade which the adventurers have
built on the island. Then whilst tackling the evil murderous pirates Jim must
find Ben Gunn's cave. The chase and search takes place upon an attractive
'Treasure Map' which is displayed on screen in sections. There are a total of
sixty-four sections to play through.

Once Ben Gunn's cave has been found the treasure is located, and must then be
taken to the ship which is anchored in Spy Glass Cove, to complete the arcade
adventure.

At the end of each game a percentage score will be given which reflects the
speed and fighting spirit with which it was played. Treasure Island can be
played time and time again to attempt to reach a 100 per cent score, which
represents total player perfection.

Loading the game

1 Put the cassette in the recorder.
2 To load, type LOAD""
  This can be achieved by:
  (a) Pressing the L key which will produce the word LOAD on the screen.
  (b) Holding down the SYMBOL SHIFT key which is at the bottom right-hand
  corner of the Spectrum - and while holding it down press the P key twice.
  This will produce two sets of quotation marks on the screen.
  Then take your finger off the SYMBOL SHIFT and press the ENTER key. The
  screen on the Spectrum will now clear, indicating that it is waiting to
  receive the program from the tape recorder.
3 Press PLAY on the tape recorder. The screen border will slowly change
  colours while searching for the information. The border changes to
  multicoloured stripes when it has found the first part of the program. The
  screen remains blank until a picture of Long John Silver appears - after
  approximately one minute. The rest of the program will then load
  automatically, and the process takes a few minutes. The Long John Silver
  picture will then disappear, to be replaced by the first screen of the
  game, and the game can commence.

If you experience any difficulty we suggest that you try loading with only
one plug in the EAR socket of the cassette deck and the same coloured plug
in the EAR socket of the Spectrum.

Please ensure that your tape is stored well away from any source of magnetic
fields - such as televisions, hi-fis, radios, and electric motors.

Controls
Jim Hawkins is moved using a joystick and Sinclair Interface 2 or by the
keyboard where Q or A are up or down and O or P move left or right.

Just avoiding the pirates is not enough to ensure success. You must perfect a
technique which involves getting close to a pirate so that he throws a
cutlass at Jim. You must move Jim swiftly out of the cutlass' path to avoid
injury.

To pick up a weapon or the treasure Jim must be moved over the object. To
throw a cutlass Jim must first be moved in the direction required and then
the fire button or M pressed.

Pressing H will hold the game. Pressing T will terminate the hold. Holding
both B and T down together will restart the game.

(C) Mr Micro Ltd 1984

(Transcribed by Robin Stuart)");
            }
            break;
        }
        return(pName.ToString());
    }
예제 #8
0
파일: Form1.cs 프로젝트: offby1/anagrams
        private void Form1_Shown(object sender, EventArgs e)
        {
            System.IO.Stream wordlist_stream;
            System.Reflection.Assembly thisExe;
            thisExe = System.Reflection.Assembly.GetExecutingAssembly();
            wordlist_stream =
                thisExe.GetManifestResourceStream("Anagrams.words");
            System.Diagnostics.Trace.Assert(wordlist_stream != null,
                "Uh oh, can't find word list inside myself!");
            toolStripStatusLabel1.Text = "Compiling dictionary ...";
            ProgressBar.Value = 0;
            ProgressBar.Maximum = (int)wordlist_stream.Length;
            listView1_Resize(sender, e);
            using (StreamReader sr = new StreamReader(wordlist_stream))
            {
                String line;
                // Read and display lines from the file until the end of
                // the file is reached.
                int linesRead = 0;
                Hashtable stringlists_by_bag = new Hashtable();
                while ((line = sr.ReadLine()) != null)
                {
                    // TODO -- filter out nonletters.  Thus "god's"
                    // should become "gods".  And since both of those
                    // are likely to appear, we need to ensure that we
                    // only store one.
                    line = line.ToLower();
                    if (!acceptable(line))
                        continue;
                    Bag aBag = new Bag(line);
                    if (!stringlists_by_bag.ContainsKey(aBag))
                    {
                        strings l = new strings();
                        l.Add(line);
                        stringlists_by_bag.Add(aBag, l);
                    }
                    else
                    {
                        strings l = (strings)stringlists_by_bag[aBag];
                        if (!l.Contains(line))
                            l.Add(line);
                    }
                    linesRead++;
                    ProgressBar.Increment(line.Length + 1); // the +1 is for the line ending character, I'd guess.

                    Application.DoEvents();
                }

                // Now convert the hash table, which isn't useful for
                // actually generating anagrams, into a list, which is.

                dictionary = new List<bag_and_anagrams>();
                foreach (DictionaryEntry de in stringlists_by_bag)
                {
                    dictionary.Add(new bag_and_anagrams((Bag)de.Key, (strings)de.Value));
                }

                // Now just for amusement, sort the list so that the biggest bags
                // come first.  This might make more interesting anagrams appear first.
                bag_and_anagrams[] sort_me = new bag_and_anagrams[dictionary.Count];
                dictionary.CopyTo(sort_me);
                Array.Sort(sort_me);
                dictionary.Clear();
                dictionary.InsertRange(0, sort_me);
            }
            toolStripStatusLabel1.Text = "Compiling dictionary ... done.";
            listView1.Enabled = true;
            input.Enabled = true;
            input.Focus();
        }
예제 #9
0
 // *sigh* this is tediously verbose
 public BagAnagrams(Bag b, strings words)
 {
     this.b     = b;
     this.words = words;
 }
예제 #10
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            System.IO.Stream           wordlist_stream;
            System.Reflection.Assembly thisExe;
            thisExe         = System.Reflection.Assembly.GetExecutingAssembly();
            wordlist_stream =
                thisExe.GetManifestResourceStream("Anagrams.words");
            System.Diagnostics.Trace.Assert(wordlist_stream != null,
                                            "Uh oh, can't find word list inside myself!");
            toolStripStatusLabel1.Text = "Compiling dictionary ...";
            ProgressBar.Value          = 0;
            ProgressBar.Maximum        = (int)wordlist_stream.Length;
            listView1_Resize(sender, e);
            using (StreamReader sr = new StreamReader(wordlist_stream))
            {
                String line;
                // Read and display lines from the file until the end of
                // the file is reached.
                int       linesRead          = 0;
                Hashtable stringlists_by_bag = new Hashtable();
                while ((line = sr.ReadLine()) != null)
                {
                    // TODO -- filter out nonletters.  Thus "god's"
                    // should become "gods".  And since both of those
                    // are likely to appear, we need to ensure that we
                    // only store one.
                    line = line.ToLower();
                    if (!acceptable(line))
                    {
                        continue;
                    }
                    Bag aBag = new Bag(line);
                    if (!stringlists_by_bag.ContainsKey(aBag))
                    {
                        strings l = new strings();
                        l.Add(line);
                        stringlists_by_bag.Add(aBag, l);
                    }
                    else
                    {
                        strings l = (strings)stringlists_by_bag[aBag];
                        if (!l.Contains(line))
                        {
                            l.Add(line);
                        }
                    }
                    linesRead++;
                    ProgressBar.Increment(line.Length + 1); // the +1 is for the line ending character, I'd guess.

                    Application.DoEvents();
                }

                // Now convert the hash table, which isn't useful for
                // actually generating anagrams, into a list, which is.

                dictionary = new List <bag_and_anagrams>();
                foreach (DictionaryEntry de in stringlists_by_bag)
                {
                    dictionary.Add(new bag_and_anagrams((Bag)de.Key, (strings)de.Value));
                }

                // Now just for amusement, sort the list so that the biggest bags
                // come first.  This might make more interesting anagrams appear first.
                bag_and_anagrams[] sort_me = new bag_and_anagrams[dictionary.Count];
                dictionary.CopyTo(sort_me);
                Array.Sort(sort_me);
                dictionary.Clear();
                dictionary.InsertRange(0, sort_me);
            }
            toolStripStatusLabel1.Text = "Compiling dictionary ... done.";
            listView1.Enabled          = true;
            input.Enabled = true;
            input.Focus();
        }