2018-03-13 HW

posted Mar 13, 2018, 6:10 AM by Konstantinovich Samuel   [ updated Mar 13, 2018, 10:10 AM ]
Goal: Pig Latin Lab:

Collaborate with your neighbor in the planning phase!

For clarification check this out briefly: https://en.wikipedia.org/wiki/Pig_Latin

1. Planning Phase

Each person should work on their own paper that can potentially be collected:

Diagram phase 1, and phase 2.

-Demonstrate how you would make each function work

-Include sample data (strings/lists) with labeled indices, 

-Include expressions+explanations that show how you will look at the various parts of the string. (e.g.   s[0:2]  #take the first two letters of the ... more text here)

-feel free to draw arrows to show what things are related, and what!

3. On the computer

-After you diagram the functions, create them in idle. 

-Include more test cases than I give

-Keep each phase as a new function so you don't lose working functions.

Phase I: Basic function


Given a single word of at least 1 character. 

words that start with a,e,i,o,u -> add 'hay' to the end of the word 

other words, move the first letter to the end, and add 'ay' to the word.

pigLatinSimple('mock') → 'ockmay'
pigLatinSimple('offer') → 'offerhay'
pigLatinSimple('david') → 'avidday'

Phase II:
pigLatin(s)  #pro tip: when something works, and you want to change it:
                    #make a new function so you always have your old working code.


words that start with any digraph (list included for your convenience) move the first two letters to the end, and add 'ay' 

Digraphs: ['bl', 'br', 'ch', 'ck', 'cl', 'cr', 'dr', 'fl', 'fr', 'gh', 'gl', 'gr', 'ng', 'ph', 'pl', 'pr', 'qu', 'sc', 'sh', 'sk', 'sl', 'sm', 'sn', 'sp', 'st', 'sw', 'th', 'tr', 'tw', 'wh', 'wr']

pigLatin('a') → 'ahay'
pigLatin('the') → 'ethay'
pigLatin('check') → 'eckchay'

Phase III:

Modify it so that the input can be a single word of at least 1 character, that can optionally have a punctuation mark afterward. 

pigLatinBest('fish!') → 'ishfay!' 
pigLatinBest('dog.') → 'ogday.' 
pigLatinBest('cat!') → 'atcay!'
pigLatin('check') → 'eckchay'

Phase IV:  Apply this function to all the words of a sentence. 
How can you break up a string so that you can run your function on the words?

Complete this at home and submit the section on codingbat : Processing text
This is the newest section and should overlap almost entirely!