Ruby Advanced (Coding) Assessment Test

Ruby Advanced (Coding)

 60 Minutes
 4 Questions


This test evaluates a candidate's expertise in Ruby, focusing on advanced programming concepts, data structures, and efficient data manipulation techniques. It covers Ruby syntax, object-oriented programming (OOP), metaprogramming, modules, and best practices for clean, maintainable code. Candidates will be tested on their ability to work with complex data structures such as arrays, hashes, trees, and linked lists, as well as implementing sorting, searching, and filtering algorithms efficiently. The assessment also includes challenges that require candidates to optimize Ruby's built-in methods, leverage enumerables, and apply functional programming techniques to manipulate data effectively. This test ensures proficiency in both theoretical understanding and real-world application of advanced Ruby programming.


Example Question:

Coding
In a distant realm, there lies a mystical forest inhabited by unique creatures known as the Elementals. These Elementals possess magical abilities represented by symbols: "<" and ">". Each symbol signifies the relationship between their elemental powers.
You are granted a mystical scroll containing a string s of length n. Within this string, each character represents the comparison between two Elementals' powers. The character s[i] is "<" if and only if the power of Elemental a[i] is less than the power of Elemental a[i]+1. Conversely, if s[i] is ">", it means the power of Elemental a[i] is greater than the power of Elemental a[i]+1.
To maintain balance within the forest, you must find an array a consisting of n+1 elements that aligns with the given string s. An array is considered compatible with the string s if the comparison between each pair of adjacent elements matches the corresponding symbol in s.

The cost of an array is determined by the number of different elements it contains. In essence, the cost represents the uniqueness of the elemental powers within the array. For instance, the cost of [1,2,5,4,2] is 4, while the cost of [13,37,42,37,13] is 3.
Your quest is to calculate the minimum cost among all arrays that are compatible with the given string s, ensuring harmony prevails within the mystical forest.

For example, the array [1,2,5,4,2] is compatible with the string "<<>>". However, there may be other arrays that are also compatible, such as [13,37,42,37,13].