Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. ###Palindrome Potential
  2.  
  3. _A palindrome is a word that reads the same forward, as it does backward_
  4.  
  5. Write a method called `could_be_palindrome?()`, that takes in String. This method determines whether or not the letters in a String could be re-arranged into a palindrome. Your method should return `true` or `false`
  6.  
  7. For instance:
  8.  
  9. ```ruby
  10. # tests
  11. could_be_palindrome?("aab") # true: "aba"
  12. could_be_palindrome?("aabbc") # true: "abcba"
  13. could_be_palindrome?("aaab") # false
  14. ```
  15.  
  16. ###Substrings
  17.  
  18. Write a method called `is_substring?`
  19.  
  20. It shoud take in 2 Strings, in this case words. The first is our original word. The second is what we're checking to see if its a substring or not. "_The catch_" is... your'e NOT allowed to use Ruby's `.include?` method.
  21.  
  22. For instance:
  23.  
  24. ```ruby
  25. our_word = 'devbootcamp'
  26. is_substring?(our_word, 'boot') # true
  27. is_substring?(our_word, 'camp') # true
  28. is_substring?(our_word, 'code') # false
  29. ```
  30.  
  31. ###Stock History
  32.  
  33. Below are the stock prices for ACME Co. They've been helping out Elmer Fudd and Wile E. Coyote for years! On Day 1, the price was 9, Day 2 it was 4 and so on.
  34.  
  35. ```ruby
  36. acme_stock_prices = [ 9, 4, 2, 1, 3, 6, 15, 13, 8 ]
  37. ```
  38.  
  39. We want to figure out a program for telling us the best time to buy and sell ACME Co. stock. In our example, it would be:
  40.  
  41. ```
  42. - Buy on Day 4
  43. - Sell on Day 7
  44. ```
  45.  
  46. Write a method called `best_prices` that takes in an Array of Integers. Return the days as an Array.
  47.  
  48. Example:
  49. ```ruby
  50. best_prices(acme_stock_prices) # [ 4, 7 ]
  51. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement