Tagged Questions
2
votes
1answer
51 views
Drawing game objects using their Z-order property
I am creating a game, with Ruby scripting.
Sprite and Label objects can be drawn on the screen. Depending on the order you draw them, one will overlap the other.
To make things easier, I want to ...
0
votes
0answers
30 views
Improvements on tree index class
I developed a QuickIndex class which serves to index arrays of stringafiable objects using a tree structure. The purpose is to then primarily to allow for fast index or include? method calls directed ...
3
votes
1answer
98 views
code optimization in ruby
I'm trying to solve the four color theorem in ruby.
A map is like this:
ccaaaa
baaadc
babcdc
bbbcdc
abcccc
And so far i have this following code but it's slow, how could I make it better ?
...
4
votes
2answers
183 views
The Next Palindrome: Is my code efficient?
I was trying to solve the Next Palindrome problem listed in SPOJ in Ruby language. Please find the problem statement here. Though i came up with the below solution, i could not get the execution time ...
2
votes
1answer
81 views
Coupon system optimization
I have the following code for my coupon system. It should work but I'm sure I can optimize it.
Any suggestions would be welcome.
@price_to_pay = @booking_request.guests * @table_offer.price_cents / ...
9
votes
4answers
1k views
Best Ruby one-liner to generate a random alphanumeric string
This is a little arbitrary, but I'm curious what people might come up with. I want to generate a random alphanumeric string in ruby, as succinctly and efficiently as possible.
([nil]*8).map { ...
4
votes
1answer
154 views
How to improve this Ruby code?
Is there any room for improvement on this code?
I use mechanize to get the links of a job listing web site. There are pages with pagination (when jobs > 25) and pages without.
If there is, then the ...
1
vote
1answer
171 views
Rails feed parser to be improved
This is my feed parser method using feedzirra. It works but I feel dirty because I can't figure out how to better this code. Any suggestion?
class Feed < ActiveRecord::Base
attr_accessible ...
3
votes
1answer
180 views
Greedy algorithm in Ruby - any suggestions?
Here is my implementation of the greedy algorithim in Ruby. Do you have any suggestions?
class Greedy
def initialize(unit, total, *coins)
@total_coins = 0
@unit = unit
@total = total
...
2
votes
2answers
105 views
Small: Setting locale
I'm new to Rails/Ruby and I would like to get feedback on my little ApplicationController which is able to detect the visitor's language. I'm especially interested in optimizations on the control ...
1
vote
1answer
232 views
Optimizing Code - need some guidance
I recently tried my hand at CodeSprint2 through Interview Street. Having not coded in quite some time, I wasn't surprised that I had difficulty writing optimized code, but on one problem in ...
5
votes
3answers
160 views
This script works but keeps timing out with longer inputs. How can I improve its speed? [Ruby]
The script takes a string such as this: (15, 176) (65, 97) (72, 43) (102, 6) (191, 189) (90, 163) (44, 168) (39, 47) (123, 37) and breaks it into an array of arrays. It then computes the largest ...