11-Section-Handout

# 11-Section-Handout - CS106X Autumn 2010 Handout 11...

This preview shows pages 1–3. Sign up to view the full content.

CS106X Handout 11 Autumn 2010 September 26 th , 2010 Section Handout Problem 1: Look And Say The look-and-say sequence is the sequence of numbers beginning as: 1 11 21 1211 111221 312211 13112221 Each number in the sequence is generated by "reciting" its predecessor, and then capturing what was said in a number format that should be clear from the example below. Reciting 111221 out loud, you’d look and say: 3 ones, followed by 2 twos, followed by 1 one, or 312211. Reading 312211 aloud, you’d say: 1 three, 1 one, 2 twos, 2 ones, or 13112221. Even if a number doesn’t fall in the actual sequence, it should be clear how to generate its look-and-say successor. Write a function called LookAndSay , which takes a number in string form, and returns its look-and-say form. You can assume the incoming string contains only digits, and that the longest run of any single digit will be less than or equal to 9. /** * Accepts the incoming string and generates the * the number that would follow it in a look-and-say * sequence. * * Examples: * LookAndSay("22") returns "22" * LookAndSay("132224444") returns "11133244" * LookAndSay("111119913333333") returns "51291173" */ string LookAndSay(string before);

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

View Full Document
2 Problem 2: http://tinyurl.com tinyurl.com is a small website that constructs small, more easily managed URLs on behalf of long, unwieldy ones. As an example, here’s a link leading to a page that outlines
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

11-Section-Handout - CS106X Autumn 2010 Handout 11...

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

View Full Document
Ask a homework question - tutors are online