You've successfully subscribed to The Poor Coder | Hackerrank Solutions
Great! Next, complete checkout for full access to The Poor Coder | Hackerrank Solutions
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Home
Author
Terms
Privacy
About
Tumblr
Pinterest
Enable dark mode
Ruby
Beeze Aal
26.Aug.2020
Hackerrank Lazy Evaluation Solution
Lazy evaluation is an evaluation strategy that delays the assessment of an expression until its value is needed. Ruby introduced a lazy enumeration feature. Lazy evaluation increases performance by avoiding needless calculations, and it has the ability to create potentially infinite data structures. Example: power_array = -> (power, array_
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Methods - Keyword Arguments Solution
In our previous challenge, we explored one way to pass a variable number of arguments to our methods. While it may seem handy feature to have, except few circumstances, you are never going to use that many variables for your method. Also, if your are passing several different types of
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Methods - Arguments Solution
In the previous challenge, we learned to use methods to abstract similar computations into logical chunks of code that otherwise would be difficult to manage. Methods, in a way, behave like a black box. The programmer works mainly on 1) inputs, 2) expected output, and 3) how it works. We
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Enumerable - group_by Solution
Another function often used with data collections is one which groups the elements according to some evaluation result. Consider the following example. Let's say you have a list of 100 integers and you want to group them according to their even and odd value. In Ruby, you can easily do
Beeze Aal
26.Aug.2020
Hackerrank Ruby Enumerables: 'any', 'all', 'none', and 'find' Solution
Ruby offers various enumerables on collections that check for validity of the objects within it. Consider the following example:> arr = [1, 2, 3, 4, 5, 6]=> [1, 2, 3, 4, 5, 6]> h = {"a" => 1, "b" => 2, "c" => 3}=> {"a" => 1, "b"
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Enumerable - reduce Solution
A common scenario that arises when using a collection of any sort, is to get perform a single type of operation with all the elements and collect the result. For example, a sum(array) function might wish to add all the elements passed as the array and return the result.
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Enumerable - collect Solution
.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-family: sans-serif} .MathJax_SVG {display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; font-size-adjust: none; text-indent:
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Enumerable - each_with_index Solution
In the previous challenge, we learned about each method being central to all of the methods provided by Enumerable class. One of such useful methods is each_with_index which allows you to iterate over items along with an index keeping count of the item. For example,> colors = ['red',
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Enumerable - Introduction Solution
.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-family: sans-serif} .MathJax_SVG {display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; font-size-adjust: none; text-indent:
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Strings - Methods II Solution
In this tutorial, we'll learn about the methods in String class that help us to search and replace portions of the string based on a text or pattern. String.include?(string) - Returns true if str contains the given string or character. Very simple! > "hello".include? "lo" #=> true
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Strings - Methods I Solution
.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-family: sans-serif} .MathJax_SVG {display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; font-size-adjust: none; text-indent:
Beeze Aal
26.Aug.2020
Hackerrank Ruby - Strings - Iteration Solution
In our encoding tutorial, we learned about the different ways Ruby 1.8 and Ruby 1.9 (and higher versions) represent strings internally. The major difference is a wide range of encoding (non-ascii) support in the later versions. This change, however, also overhauls the way strings were iterated between the
More Posts