Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
1 answer
276 views

Ruby Exercise: Implement your own "#group_by" method

Task: "Implement a method 'gruppiere', in a way that it can be invoked on all enumerable objects (Enumerable). The method receives a block and returns a hash. The items of the enumerable a grouped ...
michael.zech's user avatar
  • 5,002
0 votes
1 answer
140 views

Non-recursive factorial in Ruby

I've implemented a factorial function in a more "Ruby" way. I would like to get feedback on the algorithm. ...
justapilgrim's user avatar
6 votes
3 answers
3k views

GCD of two numbers in Ruby

I am trying to implement a algorithm for the GCD of two numbers in a functional approach. Can this be improved further, also with regards to performance? ...
tessie's user avatar
  • 315
11 votes
2 answers
2k views

Luhn algorithm in Ruby

I'm learning Ruby 2.3 and I've tried to implement a function which performs the Luhn credit card verification algorithm on an input string, returning true if it ...
Aaron Christiansen's user avatar
3 votes
2 answers
352 views

Custom map on `Array`

I have the following problem: Given an Array, apply a certain method x to each Array ...
user1934428's user avatar
5 votes
2 answers
203 views

Print the length of words as input as a histogram with horizontal bars

Input A list of words separated by any number of spaces. Output A horizontal ASCII art histogram, where the n-th line is composed by as many asterisks (*) as the n-...
Caridorc's user avatar
  • 28k
6 votes
1 answer
157 views

Monoalphatic and Polialphabetic cipher in Ruby

This code encrypts a text with mono-alphabetic and poli-alphabetic substitutions ciphers. For further info see: Mono-alphabetic/Caesar Cipher Poli-alphabetic cipher ...
Caridorc's user avatar
  • 28k
4 votes
2 answers
196 views

Transforming an array in Ruby

I watched a presentation by Dave Thomas on Elixir where he gave an example problem that he solved using functional programming. He mentioned using Ruby to solve the same problem, but did not show an ...
Mohamad's user avatar
  • 2,044
3 votes
3 answers
222 views

Evaluating a dotted quad IP address has clumsy use of inject/fold

I wrote this to consume valid IPv4 addresses in dotted-quad decimal form: ...
dcorking's user avatar
  • 321
3 votes
3 answers
456 views

Curious fractions in functional Ruby

Problem 33 in Project Euler asks: The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is ...
TCSGrad's user avatar
  • 219
1 vote
1 answer
146 views

How to rewrite recursion in a more ruby way

...
gfreezy's user avatar
  • 19