23-Section-Handout

23-Section-Handout - CS106X Winter 2008 Handout 23 February...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS106X Handout 23 Winter 2008 February 5, 2008 Section Handout Problem 1: Generating Anagrams An anagram is a word or phrase formed by the rearrangement of the letters of another word or phrase. Here are a few of the funnier ones I found this morning while drinking my coffee and surfing http://wordsmith.org/anagram . partial men is an anagram of parliament . Old West Action is an anagram of Clint Eastwood The American First Lady, Laura Bush is an anagram of I am after a cuter husband: Hillary’s! Firefox browser is an anagram of fix errors of Web We’re interested in writing code that, given a string of lowercase letters (i.e. "oldwestaction" ), manages to find any one of its anagrams. Here’s the prototype I want you to work with: bool FindAnagram(string letters, Lexicon& lex, Vector& anagram); FindAnagram should return false if an anagram couldn’t be found. Otherwise, it returns true and populates the supplied Vector<string> with the sequence of words making up the anagram. You should impose a minimum word length of 3, and you should return true as soon as you find your first anagram, and false as soon as you can tell you’ll never get an anagram out of the supplied string. Once we have FindAnagram , it’s possible to find anagrams for virtually anything: Anagram Generator: Welcome -------------------------- Please enter a string of letters: jerrycainjunior >> ninja juicy error Please enter a string of letters: peterpawlowski >> walker wipe opts Please enter a string of letters: dorissullivan >> avion dull sris
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/18/2008 for the course CS 106X taught by Professor Cain,g during the Winter '08 term at Stanford.

Page1 / 4

23-Section-Handout - CS106X Winter 2008 Handout 23 February...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online