Last active
October 19, 2015 22:12
-
-
Save Videmor/a1274d2a69c3f95c580c to your computer and use it in GitHub Desktop.
Ejercicios Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Given a sentence containing multiple words, find the frequency of a given word in that sentence. | |
| Construct a method named 'find_frequency' which accepts two arguments 'sentence' and 'word', both of which are String objects. | |
| Example: The method, given 'Ruby is The best language in the World' and 'the', should return 2 (comparison should be case-insensitive). | |
| Hint: You can use the method Array#count to count the frequency of any element in the given array. eg: | |
| [9,3,4,9,5].count(9) | |
| Will return the value 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Given an array containing some strings, return an array containing the length of those strings. | |
| You are supposed to write a method named 'length_finder' to accomplish this task. | |
| Example: | |
| Given ['Ruby','Rails','C42'] the method should return [4,5,3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Given an Array, return the elements that are present exactly once in the array. | |
| You need to write a method called non_duplicated_values to accomplish this task. | |
| Example: Given [1,2,2,3,3,4,5], the method should return [1,4,5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Given a sentence, return true if the sentence is a palindrome. | |
| You are supposed to write a method palindrome? to accomplish this task. | |
| Note Ignore whitespace and cases of characters. | |
| Example: | |
| Given "Never odd or even" the method should return true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Número elevado al cuadro, que si al sumar sus dígitos sumen igual al número devolver true, | |
| en caso contrario false. | |
| 9 ^ 2 = 81 and 8 + 1 = 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Problem Statement | |
| Given a custom class MyArray, | |
| write a 'sum' method that takes a block parameter. | |
| Example: | |
| my_array = MyArray.new([1, 2, 3]) | |
| my_array.sum gives 6 | |
| my_array.sum(10) gives 16 | |
| my_array.sum(0) {|n| n ** 2 } gives 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment