Calling method isn't returning string

I created a method to count a substring 'e' in a string passed as an argument. If there isn't a substring 'e' in the string, it should return "There is no \"e\"." I am trying to achieve this: How many times 'e' is in a string. If given string doesn...
more »

2017-07-18 22:07 (4) Answers

Solving Knights Tour using Warnsdorff's Rule

I'm currently trying to improve upon a brute force implementation of Knight's Tour by using Warnsdorff's Rule, however I feel as though I'm not understanding the algorithm, as the execution of the script is taking very long. I'm mainly looking for hi...
more »

2017-07-18 20:07 (1) Answers

Remove gems installed by old version of Ruby

A previous version of Ruby I had on my system installed gems into /usr/lib/ruby/gems/2.3.0/gems (or ~/.gem/ruby/2.3.0/gems, etc.). My current version of Ruby is 2.4.1p111 and installs gems into /usr/lib/ruby/gems/2.4.0/gems (or ~/.gem/ruby/2.4.0/gems...
more »

2017-07-18 18:07 (0) Answers

Sum of the previous elements in an array

I have a array [3.0, 3.0, 2.0, 5.0, 6.0, 10.0] For each element of the array, I need the sum of its previous elements. I know how get the previous element but not all the previous elements. last = mytab[index - 1] //change here res = (e + last)...
more »

2017-07-18 12:07 (3) Answers

Schedule tasks in smallest interval: Algorithm

Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could be done in one interval. For each interval...
more »

2017-07-18 05:07 (0) Answers

Ruby method scope?

In the following example: Main.rb def main obj = ExampleClass.new def multiply(a, b, c, d) return a * b * c * d end puts obj.multiply(1, 2, 3, 4) # this prints 24 end main ExampleClass.rb class ExampleClass def initialize end en...
more »

2017-07-17 20:07 (2) Answers

How best to propose edits to Ruby documentation?

I have a small edit that I would like to propose for existing documentation of Ruby 2.4.0 I found http://documenting-ruby.org/ and https://github.com/documenting-ruby/ruby, but the fork looks no longer maintained. How should I proceed? Should I sub...
more »

2017-07-17 03:07 (1) Answers

Hashing a string in Ruby

Hey I need to figure out how to turn this string "?q=cat&name=Tim#img=FunnyCat" into the hash ({"q" => "cat", "name" => "Tim"}) I'm very much stuck on this problem any assistance would be greatly appreciated. ...
more »

2017-07-16 22:07 (4) Answers

Finding a true integer square root from an array

I'm sure this is such a simple solution and for that I'm sorry but it's driving me mad. I'm trying to iterate over an array and find a true integer square root and if there isn't one then square the number instead. I don't know how to do Math.sqrt...
more »

2017-07-16 21:07 (5) Answers

How to uninstall Nokogiri

I'm trying to install Rails on my system using: gem install rails But I got this error: Sams-MacBook-Pro-2:/ sammy$ gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build...
more »

2017-07-16 20:07 (2) Answers

Editing page views with Irwi Wiki gem in Rails

What's the best way to edit and format page views using Irwi Wiki in Rails? Here is the controller it's set up for me: class WikiPagesController < ApplicationController acts_as_wiki_pages_controller end Though there's no views folder corresp...
more »

2017-07-16 18:07 (2) Answers

Comparing the values of two Ruby hashes

Im working on a project that requires the comparison of values within two hashes. The hash key 'title' has an array as its value, with the title of two issues within it. What I intend to achieve, is to say 'if the title in issue_yaml exists in fwpar...
more »

2017-07-15 17:07 (2) Answers

issue with ruby split

my objective is to read a txt.file, and split the contents into an array. However I am having issue with the split command. My text file content is this Acosta,1,3,0,0,0 Amezcua,2,1,2,0,2 Avalos,0,1,1,0,0 My code is this file = open("...
more »

2017-07-15 13:07 (3) Answers

Memoizing methods in frozen objects

I'm working with an abstract syntax tree, where each vertex is a subclass of a Node class. This base class is defined in a third party library, and the Node objects are frozen upon construction. Now I'm performing some expensive operations that trav...
more »

2017-07-15 07:07 (1) Answers

NoMethodError in controller

Hello I'm new at Ruby and I'm trying to make a method in my Project controller like so: def update_phase @project = Project.find(params[:id]) diff = (Date.current.year * 12 + Date.current.month) - (@project.starting.year * 12 + @project.star...
more »

2017-07-15 06:07 (1) Answers