Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###Palindrome Potential
- _A palindrome is a word that reads the same forward, as it does backward_
- 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`
- For instance:
- ```ruby
- # tests
- could_be_palindrome?("aab") # true: "aba"
- could_be_palindrome?("aabbc") # true: "abcba"
- could_be_palindrome?("aaab") # false
- ```
- ###Substrings
- Write a method called `is_substring?`
- 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.
- For instance:
- ```ruby
- our_word = 'devbootcamp'
- is_substring?(our_word, 'boot') # true
- is_substring?(our_word, 'camp') # true
- is_substring?(our_word, 'code') # false
- ```
- ###Stock History
- 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.
- ```ruby
- acme_stock_prices = [ 9, 4, 2, 1, 3, 6, 15, 13, 8 ]
- ```
- 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:
- ```
- - Buy on Day 4
- - Sell on Day 7
- ```
- Write a method called `best_prices` that takes in an Array of Integers. Return the days as an Array.
- Example:
- ```ruby
- best_prices(acme_stock_prices) # [ 4, 7 ]
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement