Newsgroups: comp.lang.ruby
From: Pawel Radecki <pawel.j.rade...@gmail.com>
Date: Sun, 9 Dec 2007 15:46:04 -0500
Local: Sun, Dec 9 2007 3:46 pm
Subject: Re: Word Loop (#149) [SOLUTION]
And here is my solution. It tries to find first suitable letter
repetition and print the whole word on the screen with the very tight loop. Suitable repetition exists when distance between identical letters is an even number greater or equal to four. #!/usr/bin/env ruby # Solution to Ruby Quiz #149 (see http://www.rubyquiz.com/quiz149.html) require 'logger' $LOG = Logger.new($stderr) #logging NO_LOOP_TEXT = "No loop." class String i=0 #repeated letter, first occurrence, loop point i=index1+1 i=index2-1; j=index1 i=index2+1; j=2 #cut all empty rows public USAGE = <<ENDUSAGE if ARGV.length!=1 input_word = ARGV[0] exit -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||