From: "yermej@..." Date: 2007-06-17T10:50:08+09:00 Subject: Re: Chris Pine Program Challenges On Jun 16, 7:38 pm, danielj wrote: > > Try inserting each input into a sorted array. > > Mmmm... I'm not quite following? Wouldn't I have to use the "sort" > method if I did that? Don't think about processing the array once you have all the inputs. Think about processing as the inputs are gathered. You start with an empty array; technically, that's already sorted. When you get the first word, you insert that and you still have a sorted array. From here on out, just insert each word so that you maintain a sorted array. >From reading the chapter, you'll be able to do this with what you've learned, but it will take two arrays and a lot of moving things back and forth. > > Maybe use a regex to check for any lowercase letters. Instead of: > > if r == r.downcase or r == r.capitalize > > use: > > if r =~ /[a-z]/ > > I would but, he has yet to talk about REGEX at that point in the > tutorial and I feel like I would be cheating :) Fair enough. Taking a quick glance at the Chris Pine online book, I think you'll be able to do what you need using swapcase and downcase. For other Ruby problems to solve, you might want to check out http://www.rubyquiz.com/ .