7
votes
4answers
300 views

Ruby-ize for loop - counting all the n-digit numbers that contain the digit 5 anywhere

I wrote this a while back when my fiance was taking a Number Theory class. I wrote about it here and it recently came back to my attention. Anytime I write a for ...
0
votes
1answer
73 views

Connect Four in Ruby - trouble with conditional return value [closed]

I'm writing a 'Connect Four` game in Ruby, and while I've been using Rails for some time, I've never used only Ruby - so you could say I'm a Ruby Noobie. The following method takes an array (the game ...
4
votes
3answers
144 views

Cleaning up code and making better loops for soccer shoot-out game

I'll start by saying I've just started with programming, and Ruby is my first language. I've made a little soccer shoot-out game. I'm having problems with the end of the code looping back to where I ...
3
votes
2answers
40 views

How to make the end of loop more readable in Ruby

There are some blocks in my code. To make it easier to read, I often append comment after the end such as end # end upto end # fileopen Because sometimes ...
1
vote
3answers
186 views

How to flatten the nested for loops?

The problem I am facing is: I need to interate through a bunch of lists, and there are separated conditions which needs to be satisfied by the list. conditons are not independent. I care about the ...