Ruby is a multi-platform open-source dynamic object-oriented interpreted language created by Yukihiro Matsumoto (Matz) in 1993.

learn more… | top users | synonyms

-1
votes
0answers
27 views

“Split the Phone Numbers” challenge

We want to extract the information from a phone number as such: [Country code]-[Local Area Code]-[Number] There might either be a '-' (ASCII value 45), or a ' ' (space, ASCII value 32) ...
4
votes
1answer
56 views

HackerRank challenge - index palindrome

I have a solution but it fails the performance for two tests. How can I speed it up? ...
6
votes
1answer
38 views

Analyzer for randomly generated names

So I recently wrote a name generator that uses a DTMC underneath (I asked about it here) and, since I'm not entirely confident I did it right, I wrote a script to check my code, or at least its ...
2
votes
0answers
27 views

Using Nokogiri to scrape Oscars winners from Wikipedia

I am scraping a Wikipedia page, getting info from that page and instantiating a new object with the information collected: ...
4
votes
1answer
91 views

Password Attacker (Google apac test problem)

Original Problem Short Summary: Given a \$M\$ possible characters all of which must be used at least once, find the number of possible combinations of length (exactly) \$N\$. The ...
4
votes
0answers
37 views

BotClean challenge

I'm going through the artificial intelligence domain at HackerRank. I'm very new to this domain and I really need a guide on how should I minimize the number of ...
8
votes
3answers
230 views

Sums of some array elements

I'm doing an archived MOOC at the moment which introduces Ruby programming. There are some assingments, yet no solutions and since the MOOC is over no one will correct those (+ the forum is down) I'm ...
7
votes
1answer
55 views

RPN calculator with interactive and non-interactive modes

While writing this review, I edited the code until it became something quite different from the original. In addition to the issues I mentioned, I ended up adding features: More operators / ...
5
votes
1answer
32 views

Formatting a price string

I'm formatting price string with the following method: ...
9
votes
1answer
51 views

Name/word generator using DTMC in Ruby

I just wrote a basic DTMC algorithm focused on generating names, though it could be used to generate lots of other things. It's designed to be run from the command line, so input is taken from a file, ...
4
votes
2answers
189 views

Simple Password Utility

I am somewhat new to ruby (but not to programming) and I want to develop a small web-app with Sinatra. I started creating a small password utility script that hashes and secures entered password. I am ...
8
votes
2answers
96 views

Confident in my code but did not pass the interview-Ruby RPN Calculator

This is my first post on code review so please correct me if I'm not following guidelines strictly. Recently I received a simple interview assignment as to implement a RPN Calculator in Ruby. The ...
5
votes
1answer
78 views

Super2048 (Google apac Test Problem)

This is my second try at writing Ruby. Stylistic feedback is very much appreciated. The problem: 2048 is played on a simple 4 x 4 grid with tiles that slide smoothly when a player moves them. ...
6
votes
2answers
55 views

Bubble sort in Ruby

For practice, I tried implementing Bubble sort in Ruby. I wasn't very sure how nested for loops would look like in Ruby. Is this the 'right way' to do this in Ruby? I found this question, but it looks ...
5
votes
3answers
98 views

Finding the Nth prime

I'm going through some of the problems over on exercism and we were asked to write a program that finds the nth prime. I know Ruby has a Prime class that handles that but the exercise doesn't allow us ...
5
votes
1answer
64 views

Sort a scrambled itinerary (Google apac test problem)

This is my first time writing ruby - and I was mainly hoping to get some feedback and stylistic pointers. The algorithm is pretty straight-forward, since Google guarantees airports aren't repeated I ...
4
votes
0answers
29 views

Creating a Wrapper for CSV Data

I am trying to complete a Ruby coding exercise. The specifics of the excercise can be found on a the level_up_exercises GitHub repo. This repo also contains the CSV file used in the exercise. I ...
2
votes
0answers
25 views

Error handling for Stripe credit card processing

I have a rails application that uses Stripe for credit card processing. Currently several exceptions are being handled anywhere a transaction takes place. The code below is being used currently in 11 ...
1
vote
1answer
28 views

Manager for customer billing and subscriptions in Rails

I'm looking to get rid of a couple dependencies that I have a sneaking suspicion are present in the code that I'm writing. Right now I have a service class that manages my subscriptions for part of ...
2
votes
2answers
29 views

Purchase controller search method

I've been trying to simplify a search method in a project that I've taken over. Is it possible to make the code any cleaner than I already have done? purchase_controller#search (original) ...
2
votes
2answers
36 views

RNA/DNA transcriber

I've been going through some of the exercises over on exercism and this is one of my solutions: a basic RNA/DNA transcriber. I was happy enough at first but now, looking at it again, the solution ...
1
vote
1answer
35 views

Project Euler 22: Names Scores — With flowchart

Full text of the problem Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. ...
13
votes
2answers
131 views

Battleship Challenge: Naval Build-up

The community challenge for this month says: Everyone has played Battleship. Let's implement the logic that sinks one. But that presumes that there's something to sink. We can't have the armada ...
0
votes
1answer
15 views

Creation of a Select in a View

I have the following code in a VIEW: ...
0
votes
0answers
14 views

Converting YARD AST parameters to a hash

I'm writing a handler for YARD that documents Mongoid fields: class User field :name, Type: String end Yard parses the method call arguments into a list of AST ...
4
votes
1answer
41 views

Is my blog controller too “Fat”?

I would like some advice which relates to the "fat model skinny controller" concept in Rails. See my show action in the Micropost controller ...
2
votes
0answers
45 views

Retrieving Robots.txt file from website for web crawler [closed]

The code works, and it does retrieve the robots.txt file. The problem is that the code looks ugly and I am looking for a way to refactor it. ...
1
vote
0answers
32 views

Ruby Script to modify and split CSVs

I have written the following script that is pointed at a CSV through it's file name and then splits the file into "drops" (for mailings) and does a couple of operations on it. As of now it works, but ...
0
votes
1answer
43 views

Converting a raw list of IDs to a consolidated array of ids [closed]

I feel I have overcomplicated the process. What can I do to improve the following code? ...
1
vote
1answer
60 views

College web-scraping LinkedIn once off test

I'm trying to use ruby LinkedIn scraper for a college project where I have to demonstrate web scraping on 20 names for their name, title etc. I've never used Ruby before but this gem seems reasonably ...
4
votes
1answer
61 views

Finding number of primes till n - Sieve of Eratosthenes

I've written a ruby implementation for Sieve of Eratosthenes algorithm, however benchmarking it against the Ruby's Prime module I have still a far slower algorithm ...
1
vote
3answers
70 views

Checking whether two strings are isomorphic

I was trying to solve a problem to determine if 2 strings are isomorphic. They are isomorphic when each character in string one can be replaced with another character in string 2. Two different ...
7
votes
1answer
49 views

Tic Tac Toe implementation in Ruby

Here's my first shot at implementing Tic Tac Toe in Ruby. After watching Gary Bernhardt's Functional Core, Imperative Shell, I thought this would be a great exercise in trying out the ideology ...
2
votes
1answer
25 views

Simple Report Data Class

I'm trying to write a class to handle the collecting and calculating of some data. My intention is to have the controller instantiate the Report object, and a very simple view display it. I figured ...
1
vote
2answers
41 views

Deduplicate data

I currently have an implementation that helps us deduplicate data but I know it's slow. Here's an example, note that I'm using OpenStruct here when really these are Mongoid objects pulled from the ...
3
votes
1answer
21 views

Using model relationships to find number of responses by a user, to posts of a certain topic type

I have a user, a micropost and a response model. The user has many microposts and has many responses. Microposts have tags using the acts as taggable gem. I need to find the number of responses a ...
3
votes
2answers
37 views

Search utility that searches through source code files

I'm working on a search utility that searches through source files. It's only the beginning of the project. It lacks a lot of features, but a backbone of the project works and it would be great if you ...
5
votes
1answer
103 views

Sudoku app for Ruby

I have written a Sudoku app for Ruby. This is my first attempt at coding in Ruby so there are sure to be lots of way to optimise it or make it more efficient. To summarise the code: it takes an input ...
0
votes
0answers
32 views

Converts large csv dataset to hash then imports into MySQL/SQLITE3 database using Sequel

The main line in this script that allows Sequel to insert records into the database table is ...
1
vote
1answer
86 views

Reduce columns to produce product keycodes

I have written the following code that achieves my desired goal of converting a "raw" CSV file into a keycoded list. The idea is that a person will get the first product they ask for, and English ...
3
votes
1answer
66 views

Project Euler #10 in Ruby - summation of primes

I'd like to have some feedback as to the performances of the algorithm. ...
5
votes
2answers
53 views

Player assignment in Tic-Tac-Toe

I am building my first OOP program, Tic Tac Toe. I want to conquer it in chunks, but the first part for me is the intialization of the program and the creation of the two players. I want to get some ...
5
votes
2answers
65 views

Transposing a 2D array

Would you have any suggestions for improvements for the code below? ...
3
votes
2answers
135 views

Logging to a File vs UDP

I'm trying to understand where my ruby implementation of this fails and hoping for an expert to shed some light on this situation. I've tried to make this a very simple example with the idea that ...
4
votes
3answers
103 views

Minimum coins algorithm in Ruby

I am working on a puzzle to find the minimum number of coins needed to buy a product. I am given three coins: 1 3 5 and also a number representing the price of a product: 11 The answer here ...
2
votes
1answer
54 views

Initializing a new user

I have a method in my rails project that initializes a new user by copying some properties of another. The method should also retain entered parameters if saving the new user is rejected. Rubocop ...
4
votes
2answers
98 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 ...
2
votes
2answers
99 views

Applying limit and offset to an array

I'm refactoring an old gateway and came across the following method: ...
3
votes
2answers
58 views

User search controller

I am using the ruby sunspot gem to create a search users function on my site. It works fine and the users controller for the index page where there is a search form is this ...
6
votes
3answers
109 views

SPOJ Adding Reversed Numbers

Recently, I was taking up this challenge and choose my favorite language 'Ruby' to do it. My following solution got accepted (Gist). For each test case, I am to reverse two numbers, add them, and ...