23S-Section-Solution

23S-Section-Solution - CS106X Winter 2008 Handout 23S...

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

View Full Document Right Arrow Icon
CS106X Handout 23S Winter 2008 February 6 – 8, 2008 Section Solution Problem 1: Generating Anagrams bool FindAnagramWithFixedPrefix(string prefix, string rest, { if (!lex.containsPrefix(prefix)) return false; if (rest == "" || FindAnagram(rest, lex, words)) { words.add(prefix); return true; } } for (int i = 0; i < rest.length(); i++) { if (FindAnagramWithFixedPrefix(prefix + rest[i], rest.substr(0, i) + rest.substr(i + 1), lex, words)) return true; } return false; } { return FindAnagramWithFixedPrefix("", letters, lex, words); } Problem 2: Creating Word Wreck Tangles /** * Function: IsReasonableToContinue * -------------------------------- * Contemplates the given board, which is assumed to be populated * from left to right, top to bottom with visible characters, all * the way through the (row, col) entry. We assume that this (row, col) * character is the most recently placed character and is the only * character that could have invalidated the partial board. We
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 / 3

23S-Section-Solution - CS106X Winter 2008 Handout 23S...

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