Skip to content

Commit

Permalink
Update exercise text to be clearer
Browse files Browse the repository at this point in the history
After undertaking it myself
  • Loading branch information
neoeno committed Apr 27, 2017
1 parent 0dc18f7 commit 0959cc3
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 31 deletions.
7 changes: 3 additions & 4 deletions exercise_1.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Write a program that takes a word and returns the pig latin version.
# Here are the rules of pig latin:
# Here are the (simplified) rules of pig latin:
#
# If the word starts with consonants, add them to the end and then add 'ay'
# If the word starts with consonant, move it to the end and then add 'ay'
# Or, if the word starts with a vowel, add 'way' to the end
# e.g. dog -> ogday
# cram -> amcray
# up -> upway
#
# Don't worry about handling multiple consonants
# Assume the words are lowercase.
# Assume your user is a developer — e.g. you don't need to write a user interface.

Expand All @@ -18,5 +18,4 @@ def pig_latin(word)

require_relative './helpers/assert_equal'
assert_equal(pig_latin('dog'), 'ogday')
assert_equal(pig_latin('cram'), 'amcray')
assert_equal(pig_latin('up'), 'upway')
20 changes: 12 additions & 8 deletions exercise_2.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Develop your work so far to treat 'qu' as a special case, so that those words
# end in 'quay'
# e.g. quick -> ickquay
# quilt -> iltquay
#  qat -> atqay
# Develop your proram to handle multiple consonants at the start of words.
#
# The rule is:
# If the word starts with one or more consonants, move them to the end.
# e.g. cram -> amcray
# sprinkle -> inklespray
#
# Still assume the words are lowercase.

def pig_latin(word)

Expand All @@ -11,6 +14,7 @@ def pig_latin(word)
## Tests:

require_relative './helpers/assert_equal'
assert_equal(pig_latin('quick'), 'ickquay')
assert_equal(pig_latin('quilt'), 'iltquay')
assert_equal(pig_latin('qat'), 'atqay')
assert_equal(pig_latin('cram'), 'amcray')
assert_equal(pig_latin('sprinkle'), 'inklespray')
assert_equal(pig_latin('dog'), 'ogday')
assert_equal(pig_latin('up'), 'upway')
13 changes: 8 additions & 5 deletions exercise_3.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Develop your work so far to preserve the existing capitalisation of the word
# e.g. Dog -> Ogday
# cram -> amcray
# Develop your work so far to treat 'qu' as a special case, so that those words
# end in 'quay'
# e.g. quick -> ickquay
# quilt -> iltquay
#  qat -> atqay

def pig_latin(word)

Expand All @@ -9,5 +11,6 @@ def pig_latin(word)
## Tests:

require_relative './helpers/assert_equal'
assert_equal(pig_latin('Dog'), 'Ogday')
assert_equal(pig_latin('cram'), 'amcray')
assert_equal(pig_latin('quick'), 'ickquay')
assert_equal(pig_latin('quilt'), 'iltquay')
assert_equal(pig_latin('qat'), 'atqay')
17 changes: 9 additions & 8 deletions exercise_4.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Develop your work so far to handle sentences
# e.g. "The quick fox jumped over the lazy dog" ->
# "Ethay ickquay oxfay umpedjay overway ethay azylay ogday"
# Develop your work so far to preserve the existing capitalisation of the word
# e.g. Dog -> Ogday
# cram -> amcray
#
# Assume words either start with a capital letter or don't — don't worry about
# other formats

def pig_latin(sentence)
def pig_latin(word)

end

## Tests:

require_relative './helpers/assert_equal'
assert_equal(
pig_latin('The quick fox jumped over the lazy dog'),
'Ethay ickquay oxfay umpedjay overway ethay azylay ogday'
)
assert_equal(pig_latin('Dog'), 'Ogday')
assert_equal(pig_latin('cram'), 'amcray')
12 changes: 6 additions & 6 deletions exercise_5.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Write the program to reverse the above
# e.g. "Ethay uickqay oxfay umpedjay overway ethay azylay ogday" ->
# "The quick fox jumped over the lazy dog"
# Develop your work so far to handle sentences
# e.g. "The quick fox jumped over the lazy dog" ->
# "Ethay ickquay oxfay umpedjay overway ethay azylay ogday"

def reverse_pig_latin(sentence)
def pig_latin_sentence(sentence)

end

## Tests:

require_relative './helpers/assert_equal'
assert_equal(
reverse_pig_latin('Ethay ickquay oxfay umpedjay overway ethay azylay ogday'),
'The quick fox jumped over the lazy dog'
pig_latin_sentence('The quick fox jumped over the lazy dog'),
'Ethay ickquay oxfay umpedjay overway ethay azylay ogday'
)
15 changes: 15 additions & 0 deletions exercise_6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Write the program to reverse the above
# e.g. "Ethay uickqay oxfay umpedjay overway ethay azylay ogday" ->
# "The quick fox jumped over the lazy dog"

def pig_latin_sentence_reverse(sentence)

end

## Tests:

require_relative './helpers/assert_equal'
assert_equal(
pig_latin_sentence_reverse('Ethay ickquay oxfay umpedjay overway ethay azylay ogday'),
'The quick fox jumped over the lazy dog'
)

0 comments on commit 0959cc3

Please sign in to comment.