[#253828] Getting the last N bytes of a string: — Brian Candler <B.Candler@...>

What's the simplest way to get only the last 10 bytes of a string?

21 messages 2007/06/01

[#253837] FizzBuzz (#126) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

177 messages 2007/06/01
[#253853] Re: [QUIZ] FizzBuzz (#126) — Hans Fugal <fugalh@...> 2007/06/01

Ruby Quiz wrote:

[#253854] Re: FizzBuzz (#126) — Paul Novak <novakps@...> 2007/06/01

On Jun 1, 9:51 am, Hans Fugal <fug...@zianet.com> wrote:

[#253885] Re: [QUIZ] FizzBuzz (#126) — Daniel Martin <martin@...> 2007/06/01

Hans Fugal <fugalh@zianet.com> writes:

[#253945] Re: [QUIZ] FizzBuzz (#126) — Morton Goldberg <m_goldberg@...> 2007/06/02

On Jun 1, 2007, at 8:28 AM, Ruby Quiz wrote:

[#254215] Re: [QUIZ] FizzBuzz (#126) — James Edward Gray II <james@...> 2007/06/04

On Jun 1, 2007, at 10:37 PM, Morton Goldberg wrote:

[#253969] Re: [QUIZ] FizzBuzz (#126) — Daniel Martin <martin@...> 2007/06/02

Ruby Quiz <james@grayproductions.net> writes:

[#254095] Re: [QUIZ] FizzBuzz (#126) — Michael Glaesemann <grzm@...> 2007/06/03

My first Ruby Quiz submission.

[#254096] Re: FizzBuzz (#126) — Joshua Ballanco <jballanc@...> 2007/06/03

So, I've got to lay claim to the 56 byte solution:

[#254097] Re: FizzBuzz (#126) — "Robert Dober" <robert.dober@...> 2007/06/03

On 6/3/07, Joshua Ballanco <jballanc@gmail.com> wrote:

[#254104] Re: FizzBuzz (#126) — Joshua Ballanco <jballanc@...> 2007/06/03

Robert Dober wrote:

[#253838] nested methods don't really exist?! — Artur Merke <am@...>

Hi,

28 messages 2007/06/01
[#253906] Re: nested methods don't really exist?! — Robert Klemme <shortcutter@...> 2007/06/01

On 01.06.2007 14:36, Artur Merke wrote:

[#253919] Re: nested methods don't really exist?! — Trans <transfire@...> 2007/06/01

[#253961] Re: nested methods don't really exist?! — Robert Klemme <shortcutter@...> 2007/06/02

On 01.06.2007 23:14, Trans wrote:

[#253967] Re: nested methods don't really exist?! — "Robert Dober" <robert.dober@...> 2007/06/02

On 6/2/07, Robert Klemme <shortcutter@googlemail.com> wrote:

[#253893] Help with emailing attachments with Ruby... — grooveska <ryangs@...>

I am working on a script that will send an email with a .csv file

11 messages 2007/06/01

[#254054] No way of looking for a regrexp match starting from a particular point in a string? — Kenneth McDonald <kenneth.m.mcdonald@...>

I'm probably just missing something obvious, but I haven't found a way

26 messages 2007/06/03
[#254056] Re: No way of looking for a regrexp match starting from a particular point in a string? — Nobuyoshi Nakada <nobu@...> 2007/06/03

Hi,

[#254059] Re: No way of looking for a regrexp match starting from a particular point in a string? — "Patrick Hurley" <phurley@...> 2007/06/03

On 6/3/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:

[#254063] Re: No way of looking for a regrexp match starting from a particular point in a string? — Nobuyoshi Nakada <nobu@...> 2007/06/03

Hi,

[#254235] Re: No way of looking for a regrexp match starting from a particular point in a string? — "Robert Dober" <robert.dober@...> 2007/06/04

On 6/3/07, Kenneth McDonald <kenneth.m.mcdonald@sbcglobal.net> wrote:

[#254132] FizzBuzz (#126) — "Christian Roese" <croese@...>

Great quiz, really got me thinking about other ways to solve this

16 messages 2007/06/03
[#254277] Re: [QUIZ] FizzBuzz (#126) — "Mike Moore" <blowmage@...> 2007/06/04

I didn't spend any time golfing this quiz, so I don't have anything crazy to

[#254217] code problems — "david karapetyan" <dkarapetyan@...>

why is the following code not valid

18 messages 2007/06/04
[#254218] Re: code problems — Nobuyoshi Nakada <nobu@...> 2007/06/04

Hi,

[#254219] Re: code problems — "david karapetyan" <dkarapetyan@...> 2007/06/04

thanks. i didn't realize i had to provide the block as well when i was

[#254223] Re: code problems — Nobuyoshi Nakada <nobu@...> 2007/06/04

Hi,

[#254291] Re: code problems — fREW <frioux@...> 2007/06/04

On 6/3/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:

[#254250] Deleting a file - is there a less clumsy way to do this? — "Ronald Fischer" <ronald.fischer@...>

In my application, I often have blocks of code, where during preparation

13 messages 2007/06/04

[#254332] Reverse-range alternatives? — Kenneth McDonald <kenneth.m.mcdonald@...>

Since a reverse range (eg. 4...1) is functionally almost the same as an

11 messages 2007/06/04

[#254452] David Black's book _Ruby for Rails — finetan@...

Hi all

16 messages 2007/06/05

[#254459] [QUIZ] FizzBuzz (#126) [solution #1] — MenTaLguY <mental@...>

I've got two solutions this go-round. First, the solution I would present were I asked to do this in an actual job interview:

13 messages 2007/06/05

[#254467] Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...>

Hello, I'm working on Gecode/R, a Ruby interface to Gecode[0], allowing

24 messages 2007/06/05
[#254477] Re: Gecode/R - Request for syntax feedback — James Edward Gray II <james@...> 2007/06/05

On Jun 5, 2007, at 2:43 PM, Andreas Launila wrote:

[#254526] Re: Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...> 2007/06/06

James Edward Gray II wrote:

[#254544] Re: Gecode/R - Request for syntax feedback — James Edward Gray II <james@...> 2007/06/06

On Jun 6, 2007, at 5:21 AM, Andreas Launila wrote:

[#254561] Re: Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...> 2007/06/06

James Edward Gray II wrote:

[#254583] Re: Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...> 2007/06/06

Andreas Launila wrote:

[#254639] Globals not incrementing inside block — "Todd A. Jacobs" <tjacobs-sndr-019fdb@...>

I have the following snippet:

13 messages 2007/06/07
[#254642] Re: Globals not incrementing inside block — "Harry Kakueki" <list.push@...> 2007/06/07

On 6/7/07, Todd A. Jacobs <tjacobs-sndr-019fdb@codegnome.org> wrote:

[#254661] Mutually-Recursive Functions — Revence Kalibwani <revence27@...>

Ruby doesn't seem to do mutually-recursive functions. Or is it some

15 messages 2007/06/07
[#254664] Re: Mutually-Recursive Functions — Dan Zwell <dzwell@...> 2007/06/07

Revence Kalibwani wrote:

[#254665] Re: Mutually-Recursive Functions — Revence Kalibwani <revence27@...> 2007/06/07

Dan Zwell wrote:

[#254673] What about a 'series' type? — Peter Marsh <evil_grunger@...>

I'm sure everyone is fimilar with ranges:

17 messages 2007/06/07
[#254685] Re: What about a 'series' type? — seebs@... (Peter Seebach) 2007/06/07

In message <cd08f63ca2ad51e567d4288410f593da@ruby-forum.com>, Peter Marsh writes:

[#254686] Re: What about a 'series' type? — SonOfLilit <sonoflilit@...> 2007/06/07

Actually, the syntax:

[#254717] Problem with getting info from several websites — "Tom Bombadil" <bombadil.tom@...>

Hi there,

14 messages 2007/06/07
[#254741] Re: Problem with getting info from several websites — George Malamidis <george@...> 2007/06/07

Hi,

[#254799] Re: Problem with getting info from several websites — "Tom Bombadil" <bombadil.tom@...> 2007/06/08

George,

[#254743] Installing Curb Was: Re: ruby libcurl maintainer? — "Jano Svitok" <jan.svitok@...>

On 6/7/07, Md.elme focruzzaman Shuvo <shuvo.razi@gmail.com> wrote:

11 messages 2007/06/07
[#254816] Installing Curb Was: Re: ruby libcurl maintainer? — "Md.elme focruzzaman Shuvo" <shuvo.razi@...> 2007/06/08

Jano Svitok wrote:

[#254808] newbie question about Ri — Grehom <grehom@...>

I just installed the latest Windows version from Activestate (having

13 messages 2007/06/08

[#254812] practical ruby console on windows? — =?iso-8859-2?q?Kiripolszky_K=E1roly?= <karoly.kiripolszky@...>

Ehlo,

5 messages 2007/06/08

[#254831] Mexican Blanket (#127) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

16 messages 2007/06/08

[#254863] Synchronized attr_accessor — Nasir Khan <rubylearner@...>

I have a fairly repetitive use case of having to define attributes and

23 messages 2007/06/08
[#254865] Re: Synchronized attr_accessor — MenTaLguY <mental@...> 2007/06/08

On Sat, 9 Jun 2007 04:34:42 +0900, Nasir Khan <rubylearner@gmail.com> wrote:

[#254867] Re: Synchronized attr_accessor — Nasir Khan <rubylearner@...> 2007/06/08

This is about having a instance variable always accessed under a lock,

[#254879] Re: Synchronized attr_accessor — MenTaLguY <mental@...> 2007/06/08

On Sat, 9 Jun 2007 04:55:24 +0900, Nasir Khan <rubylearner@gmail.com> wrote:

[#254886] Re: Synchronized attr_accessor — Nasir Khan <rubylearner@...> 2007/06/08

There is no big picture.

[#254890] Re: Synchronized attr_accessor — MenTaLguY <mental@...> 2007/06/08

On Sat, 9 Jun 2007 06:54:04 +0900, Nasir Khan <rubylearner@gmail.com> wrote:

[#254900] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/09

Yeah I see what you guys mean...I was a little delusional. Now I

[#254915] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/09

Actually facets/more/synchash.rb does what I was looking for hash.

[#254943] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/09

Prodding it further I could come up with a method synchronizer.

[#255049] Re: Synchronized attr_accessor — "Caleb Clausen" <vikkous@...> 2007/06/10

Nasir Khan wrote:

[#255073] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/11

Thanks for the feedback. Here is a refinement -

[#255093] Re: Synchronized attr_accessor — "Caleb Clausen" <vikkous@...> 2007/06/11

On 6/10/07, Nasir Khan <rubylearner@gmail.com> wrote:

[#254864] trouble running ruby programs — Hydro_Flame XZ18 <hydroflame@...>

I'm a newbie programmer and I just downloaded ruby today. I must say I'm

14 messages 2007/06/08
[#254866] Re: trouble running ruby programs — Peter Szinek <peter@...> 2007/06/08

> Can anyone help? I'm running Windows XP if that helps at all.

[#254870] Re: trouble running ruby programs — Jacob Gillie <hydroflame@...> 2007/06/08

I tried going to the command prompt, making sure the file was in the

[#254871] Re: trouble running ruby programs — "Michael W. Ryder" <_mwryder@...> 2007/06/08

Jacob Gillie wrote:

[#254917] Ruby wildcard command line argument auto expansion — Michael Jia <z_jia@...>

I want to pass in wildcard file names, and use it to match file names

14 messages 2007/06/09

[#254974] Passing block to Proc#call — "Erwin Abbott" <erwin.abbott@...>

I'd like to do something like:

13 messages 2007/06/10

[#254975] Overloading Array Subtraction operator — Nicko <anko.com@...>

Hi,

15 messages 2007/06/10
[#254978] Re: Overloading Array Subtraction operator — "Erwin Abbott" <erwin.abbott@...> 2007/06/10

The - operator compares objects by their ID, so they aren't removed

[#254986] JRuby 1.0 Released — Thomas Enebo <Thomas.Enebo@...>

The JRuby community is pleased to announce the release of JRuby 1.0!

14 messages 2007/06/10

[#254989] fun with "case" — Robert Klemme <shortcutter@...>

16 messages 2007/06/10

[#255013] Serious danger of being impressed — Mark Carter <me@...>

I'm mostly into Python, and decided to have a go at writing a little

34 messages 2007/06/10
[#255038] Re: Serious danger of being impressed — Chad Perrin <perrin@...> 2007/06/10

On Mon, Jun 11, 2007 at 12:20:12AM +0900, Mark Carter wrote:

[#255096] Re: Serious danger of being impressed — John Joyce <dangerwillrobinsondanger@...> 2007/06/11

[#255103] Re: Serious danger of being impressed — Chad Perrin <perrin@...> 2007/06/11

On Mon, Jun 11, 2007 at 03:42:03PM +0900, John Joyce wrote:

[#255044] Requiring more than one file? — Marc Heiler <shevegen@...>

require does accept ony word, which should be the name that has

13 messages 2007/06/10

[#255142] Custom Mutex methods undefined by fastthread — Alex Young <alex@...>

At the risk of asking an FAQ, I've run into the following problem:

12 messages 2007/06/11

[#255181] a matter of style — Bas van Gils <bas@...>

22 messages 2007/06/11
[#255188] Re: a matter of style — Anthony Martinez <pi@...> 2007/06/11

On Tue, Jun 12, 2007 at 03:10:49AM +0900, Bas van Gils wrote:

[#255299] Re: a matter of style — dblack@... 2007/06/12

Hi --

[#255202] Ruby way to update a file in place — Li Chen <chen_li3@...>

Hi all,

12 messages 2007/06/11

[#255258] how to make a[2][2][3]=4 work? — gz zz <gpygood@126.com>

a=Hash.new{|h,k|

16 messages 2007/06/12

[#255289] Generate a grid of cells, and give characteristics — Joop Van den tillaart <tillaart36@...>

Hi you all I am new to this forum and also quite new to ruby...I have

12 messages 2007/06/12
[#255303] Re: Generate a grid of cells, and give characteristics — "Harry Kakueki" <list.push@...> 2007/06/12

On 6/12/07, Joop Van den tillaart <tillaart36@hotmail.com> wrote:

[#255306] Re: Generate a grid of cells, and give characteristics — Joop Van den tillaart <tillaart36@...> 2007/06/12

Harry Kakueki wrote:

[#255315] Re: Generate a grid of cells, and give characteristics — "Harry Kakueki" <list.push@...> 2007/06/12

On 6/12/07, Joop Van den tillaart <tillaart36@hotmail.com> wrote:

[#255373] Quick sed replacemnt — yitzhakbg <yitzhakbg@...>

I need a quicky which I can't do in sed and I did it very clumsily.

14 messages 2007/06/12

[#255651] Changing registry values with Win32::Registry — Collin Miller <collintmiller@...>

I'm trying to change a registry value for an IPTV SDK

12 messages 2007/06/14
[#255699] Re: Changing registry values with Win32::Registry — "Jano Svitok" <jan.svitok@...> 2007/06/15

On 6/14/07, Collin Miller <collintmiller@gmail.com> wrote:> I'm trying to change a registry value for an IPTV SDK>> This code:>> Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\> \").write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)>> Returns this error:>> Win32::Registry::Error: Access is denied.> from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'> from (irb):150> from ⊂:0>> Anybody know how I can ensure access to this key?

[#255664] Reasonable practice? — Trans <transfire@...>

It the following reasonable? How thread safe is it?

14 messages 2007/06/14

[#255672] Re: class destruction (evil genius metaprogramming) — "Rick DeNatale" <rick.denatale@...>

On 6/14/07, Giles Bowkett <gilesb@gmail.com> wrote:

12 messages 2007/06/15

[#255737] Verbal Arithmetic (#128) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

29 messages 2007/06/15

[#255760] Using extend for initialization settings? — Trans <transfire@...>

It's not uncommon to see initialize method take a hash or a setting

16 messages 2007/06/15
[#255784] Re: Using extend for initialization settings? — Robert Klemme <shortcutter@...> 2007/06/15

On 15.06.2007 16:44, Trans wrote:

[#255797] Re: Using extend for initialization settings? — Trans <transfire@...> 2007/06/15

[#255864] Adding new value (in array) to existing key in a hash — Gilbert Lau <gilbertlsk@...>

Hi all,

12 messages 2007/06/16
[#255866] Re: Adding new value (in array) to existing key in a hash — "Harry Kakueki" <list.push@...> 2007/06/16

On 6/16/07, Gilbert Lau <gilbertlsk@gmail.com> wrote:

[#255873] Re: Adding new value (in array) to existing key in a hash — Gilbert Lau <gilbertlsk@...> 2007/06/16

Harry Kakueki wrote:

[#255871] Error in ancestor? — "Robert Dober" <robert.dober@...>

Hi list

39 messages 2007/06/16
[#256036] Re: Error in ancestor? — Sylvain Joyeux <sylvain.joyeux@...> 2007/06/18

I launched a discussion about this on Ruby-core. I think there were no

[#256193] Re: Error in ancestor? — "Robert Dober" <robert.dober@...> 2007/06/19

On 6/18/07, Sylvain Joyeux <sylvain.joyeux@polytechnique.org> wrote:

[#256204] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/19

On 6/19/07, Robert Dober <robert.dober@gmail.com> wrote:

[#256236] Re: Error in ancestor? — dblack@... 2007/06/19

Hi --

[#256486] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/21

On 6/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256492] Re: Error in ancestor? — dblack@... 2007/06/21

Hi --

[#256594] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/22

On 6/21/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256595] Re: Error in ancestor? — dblack@... 2007/06/22

Hi --

[#256598] Re: Error in ancestor? — "Gregory Brown" <gregory.t.brown@...> 2007/06/22

On 6/22/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256700] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/23

On 6/22/07, Gregory Brown <gregory.t.brown@gmail.com> wrote:

[#255911] Chris Pine Program Challenges — danielj@...

puts 'Type in as many words as you want'

13 messages 2007/06/16

[#255980] Parsing strings — NB88 <germans88@...>

Quick question, is there a method for deleting substrings from within a

15 messages 2007/06/18

[#256062] Another Easy Beginner Question — danielj <danielj@...>

17 messages 2007/06/18

[#256131] local vars clobbered by un-run code — Trans <transfire@...>

Err...

13 messages 2007/06/19

[#256243] Ruby MVC — poopdeville@...

Hi Everybody,

14 messages 2007/06/20

[#256299] Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...>

Hello everybody,

55 messages 2007/06/20
[#256311] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Trans <transfire@...> 2007/06/20

[#256357] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

>> Hello everybody,

[#256361] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Robert Klemme <shortcutter@...> 2007/06/21

On 21.06.2007 11:06, Alexander Presber wrote:

[#256364] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

Am 21.06.2007 um 11:20 schrieb Robert Klemme:

[#256365] Re: Behaviour of Enumerables reject vs. select mixed into Hash — dblack@... 2007/06/21

Hi --

[#256367] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Robert Dober" <robert.dober@...> 2007/06/21

On 6/21/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256370] Re: Behaviour of Enumerables reject vs. select mixed into Hash — dblack@... 2007/06/21

Hi --

[#256498] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Rick DeNatale" <rick.denatale@...> 2007/06/21

On 6/21/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256369] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

[#256374] Re: Behaviour of Enumerables reject vs. select mixed into Hash — dblack@... 2007/06/21

Hi --

[#256377] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

[#256385] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Robert Dober" <robert.dober@...> 2007/06/21

On 6/21/07, Alexander Presber <aljoscha@weisshuhn.de> wrote:

[#256401] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Trans <transfire@...> 2007/06/21

[#256414] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Robert Dober" <robert.dober@...> 2007/06/21

On 6/21/07, Trans <transfire@gmail.com> wrote:

[#256423] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

>> module Enumerable

[#256310] Do You Understand Regular Expressions? — growlatoe@...

Hi all.

20 messages 2007/06/20
[#256317] Re: Do You Understand Regular Expressions? — "Axel Etzold" <AEtzold@...> 2007/06/20

> irb(main):001:0> "hello".scan(/.*/)

[#256324] Re: Do You Understand Regular Expressions? — Daniel DeLorme <dan-ml@...42.com> 2007/06/20

Axel Etzold wrote:

[#256386] Re: Do You Understand Regular Expressions? — "Stephen Ball" <sdball@...> 2007/06/21

On 6/20/07, Daniel DeLorme <dan-ml@dan42.com> wrote:

[#256426] Ruby extensions question.. — Aaron Smith <beingthexemplary@...>

So I'm getting slightly confused with writing ruby extensions and what

17 messages 2007/06/21
[#256430] Re: Ruby extensions question.. — james.d.masters@... 2007/06/21

On Jun 21, 10:22 am, Aaron Smith <beingthexempl...@gmail.com> wrote:

[#256442] Re: Ruby extensions question.. — Aaron Smith <beingthexemplary@...> 2007/06/21

unknown wrote:

[#256450] Re: Ruby extensions question.. — MenTaLguY <mental@...> 2007/06/21

On Fri, 22 Jun 2007 03:55:11 +0900, Aaron Smith <beingthexemplary@gmail.com> wrote:

[#256469] Re: Ruby extensions question.. — Aaron Smith <beingthexemplary@...> 2007/06/21

MenTaLguY wrote:

[#256473] Re: Ruby extensions question.. — MenTaLguY <mental@...> 2007/06/21

On Fri, 22 Jun 2007 05:28:17 +0900, Aaron Smith <beingthexemplary@gmail.com> wrote:

[#256447] Ruby doesn't know how to multiply — "rjprado@..." <rjprado@...>

Hello,

45 messages 2007/06/21
[#256462] Re: Ruby doesn't know how to multiply — "rjprado@..." <rjprado@...> 2007/06/21

On Jun 21, 3:21 pm, "rjpr...@gmail.com" <rjpr...@gmail.com> wrote:

[#256484] Re: Ruby doesn't know how to multiply — Lloyd Linklater <lloyd@2live4.com> 2007/06/21

> Yes, you are all right. It's a common problem. I have confirmed this

[#256509] Re: Ruby doesn't know how to multiply — Yukihiro Matsumoto <matz@...> 2007/06/22

Hi,

[#256512] Re: Ruby doesn't know how to multiply — "Michael W. Ryder" <_mwryder@...> 2007/06/22

Yukihiro Matsumoto wrote:

[#256514] Re: Ruby doesn't know how to multiply — "Gregory Brown" <gregory.t.brown@...> 2007/06/22

On 6/21/07, Michael W. Ryder <_mwryder@worldnet.att.net> wrote:

[#256517] Re: Ruby doesn't know how to multiply — Rob Biedenharn <Rob@...> 2007/06/22

On Jun 21, 2007, at 8:48 PM, Gregory Brown wrote:

[#256519] Re: Ruby doesn't know how to multiply — "Michael W. Ryder" <_mwryder@...> 2007/06/22

Rob Biedenharn wrote:

[#256556] avoiding nil.methodcalls short and cheap — Thorsten Rossner <rossnet@...>

Hi,

17 messages 2007/06/22

[#256675] Regexp to split name? — Alex MacCaw <maccman@...>

Does anyone have an example of splitting a name into first and last

15 messages 2007/06/23
[#256676] Re: Regexp to split name? — darren kirby <bulliver@...> 2007/06/23

quoth the Alex MacCaw:

[#256713] Named/positional method args — darren kirby <bulliver@...>

I have a method here that takes two arguments. Both are optional, with

19 messages 2007/06/23

[#256748] LSRC Name Picker (#129) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

44 messages 2007/06/24
[#256749] Re: [QUIZ] LSRC Name Picker (#129) — James Edward Gray II <james@...> 2007/06/24

Sorry the quiz was late this week.

[#256811] Helper to create multi-dimensional arrays — Anthony Martinez <pi@...>

I came up with this method really quick to create x*y arrays in Ruby. It

21 messages 2007/06/24
[#256816] Ruby Debugger — Dick Summerfield <ds@...> 2007/06/24

Hello everybody,

[#257017] Probably an FAQ, but... — David Rush <kumoyuki@...>

Hi all,

13 messages 2007/06/26
[#257023] Re: Probably an FAQ, but... — Morton Goldberg <m_goldberg@...> 2007/06/26

On Jun 26, 2007, at 5:00 AM, David Rush wrote:

[#257033] how much to charge for a freelance project in ruby in the states — urielka <uriel.katz@...>

i work in Israel and i wanted to know how much should i charge per

9 messages 2007/06/26

[#257207] ActiveRecord (not necessarily rails) — "shawn bright" <nephish@...>

Hello all,

11 messages 2007/06/27

[#257228] Ajax with Ruby problem — Gale CC <galecho@...>

I'm a newbie to both Ruby and Ajax. I'm trying to use Ruby to handle the

13 messages 2007/06/27

[#257246] Array Problem, sort Array — Cool Wong <coolwong85@...>

[code]

23 messages 2007/06/28
[#257248] Re: Array Problem, sort Array — "list. rb" <list.rb@...> 2007/06/28

["a", "a", "a", "b", "b", "c", "c", "c","d", "d", "e"].uniq.sort

[#257342] Help with regular expression — "toulax@..." <toulax@...>

How can I make a regular expression that will match everything, unless

17 messages 2007/06/28
[#257343] Re: Help with regular expression — Philip Hallstrom <ruby@...> 2007/06/28

> How can I make a regular expression that will match everything, unless

[#257346] Re: Help with regular expression — "toulax@..." <toulax@...> 2007/06/28

On Jun 28, 4:00 pm, Philip Hallstrom <r...@philip.pjkh.com> wrote:

[#257353] Re: Help with regular expression — "Axel Etzold" <AEtzold@...> 2007/06/28

I think what you want is what's called negative lookahead.

[#257383] newby non/programmer trying to understand classes — "weathercoach@..." <weathercoach@...>

Hello.

15 messages 2007/06/28

[#257428] Where to start in parsing? — "Hakusa@..." <Hakusa@...>

I haven't programmed in a while, but I want to get back with doing

10 messages 2007/06/29

[#257454] Feature Request: Special file '-' denoting stdin/stdout — "Ronald Fischer" <ronald.fischer@...>

I would like to propose a feature for Ruby which can be

12 messages 2007/06/29
[#257471] Re: Feature Request: Special file '-' denoting stdin/stdout — Erik Veenstra <erikveen@...> 2007/06/29

It should be mentioned that both File.new and File.open are

[#257746] Re: Feature Request: Special file '-' denoting stdin/stdout — "Ronald Fischer" <ronald.fischer@...> 2007/07/02

[#257573] is it bug? for — Chung Chung <bkeh12@...>

[root@home1 ~]# ruby -v

16 messages 2007/06/30

[#257601] de-camelcase a filename — Aaron Smith <beingthexemplary@...>

how can a take a string file name like MyTestCase.rb and change it to

15 messages 2007/06/30

[#257609] apt-get installs 1.8.5 on ubuntu 7.0.4 — "D. Krmpotic" <david.krmpotic@...>

hi!

11 messages 2007/06/30

Re: [QUIZ] Verbal Arithmetic (#128)

From: "Glen F. Pankow" <Glen.F.Pankow@...>
Date: 2007-06-18 11:33:03 UTC
List: ruby-talk #256029
#! /usr/bin/env ruby
#
#  quiz-128  --  Ruby Quiz #128  --  Verbal Arithmetic.
#
#  Usage:  quiz-128 [ -v ] '<equation string>'
#     or:  quiz-128 [ -v ] <addend> <addend> [ <addend> ... ] <sum>
#
#  See the Ruby Quiz #128 documentation for more information
#  (http://www.rubyquiz.com/quiz128.html).
#
#  Glen Pankow      06/17/07        Original version.
#
#  Licensed under the Ruby License.
#
#-----------------------------------------------------------------------------
#
#  I take a slightly different approach to this quiz:  I build up code that
#  kinda-sorta models addition as taught in U.S. elementary schools (taking
#  into account the various constraints of the problem), then eval it.
#
#  And instead of generating permutations of unassigned digits and using
#  recursion for backtracking, I have a single array of digits that is used
#  sort of as a mask (nil entries mark assigned digits) and use Ruby's
#  wonderful magic iterator facility to scan through it.
#
#  $ uname -srmpio
#  Linux 2.6.9-55.ELsmp i686 i686 i386 GNU/Linux
#
#  $ time ./quiz-128 'send + more = money'
#  d = 7, e = 5, y = 2, n = 6, r = 8, o = 0, s = 9, m = 1
#      1   0   1   1
#        s:9 e:5 n:6 d:7
#  +     m:1 o:0 r:8 e:5
#  ---------------------
#    m:1 o:0 n:6 e:5 y:2
#  0.065u 0.003s 0:00.07 85.7%     0+0k 0+0io 0pf+0w
#
#  $ time ./quiz-128 forty ten ten sixty
#  y = 6, n = 0, t = 8, e = 5, r = 7, x = 4, o = 9, i = 1, f = 2, s = 3
#      1   2   1   0
#    f:2 o:9 r:7 t:8 y:6
#            t:8 e:5 n:0
#  +         t:8 e:5 n:0
#  ---------------------
#    s:3 i:1 x:4 t:8 y:6
#  0.029u 0.002s 0:00.03 66.6%     0+0k 0+0io 0pf+0w
#
#  $ time ./quiz-128 eat+that=apple
#  t = 9, e = 8, a = 1, l = 3, h = 2, p = 0
#      1   1   0   1
#            e:8 a:1 t:9
#  +     t:9 h:2 a:1 t:9
#  ---------------------
#    a:1 p:0 p:0 l:3 e:8
#  0.008u 0.002s 0:00.01 0.0%      0+0k 0+0io 0pf+0w
#
#  $ time ./quiz-128 ruby rubber baby buggy bumper
#  y = 0, r = 7, b = 8, e = 1, g = 4, u = 2, a = 3, p = 9, m = 6
#  ...
#  y = 0, r = 7, b = 8, e = 5, g = 4, u = 2, a = 3, p = 9, m = 6
#      1   2   1   2   0
#            r:7 u:2 b:8 y:0
#    r:7 u:2 b:8 b:8 e:5 r:7
#            b:8 a:3 b:8 y:0
#  +     b:8 u:2 g:4 g:4 y:0
#  -------------------------
#    b:8 u:2 m:6 p:9 e:5 r:7
#  0.120u 0.002s 0:00.13 92.3%     0+0k 0+0io 0pf+0w
#


class Array

    #
    # For each non-nil element of the current array, (destructively) set it to
    # nil (i.e., 'marking' it), yield the original value (to the assumed block),
    # and restore it back to what it originally was (i.e., 'unmarking' it).
    #
    # For example, the code:
    #    array = [ 0, nil, 2, 3 ]
    #    p "before: array = #{array.inspect}"
    #    array.unmarkeds { |elem| p "elem = #{elem}, array = #{array.inspect}" }
    #    p "after: array = #{array.inspect}"
    # would print:
    #    before: array = [0, nil, 2, 3]
    #    elem = 0, array = [nil, nil, 2, 3]
    #    elem = 2, array = [0, nil, nil, 3]
    #    elem = 3, array = [0, nil, 2, nil]
    #    after: array = [0, nil, 2, 3]
    #
    def unmarkeds
        (0...size).each do |i|
            next if (at(i).nil?)
            elem = at(i)  ;  self[i] = nil
            yield elem
            self[i] = elem
        end
    end

    #
    # If the <i>-th element of the current array is nil, do nothing.  Otherwise
    # (destructively) set it to nil (i.e., 'marking' it), yield (to the assumed
    # block), and restore it back to what it originally was (i.e., 'unmarking'
    # it).  This is basically the guts of unmarkeds(), and is provided for safe
    # manual element marking.
    #
    def if_unmarked(i)
        return if (at(i).nil?)
        elem = at(i)  ;  self[i] = nil
        yield
        self[i] = elem
    end

    #
    # Note:  typically one might say 'yield elem, self' in these methods, but
    # I don't need them for this application due to Ruby's scoping mechanism.
    #
end


#
# Process the command-line arguments of addend strings and the sum string.
#
verbose = false
addend_strs = [ ]
ARGV.each do |arg|
    if (arg == '-v')
        verbose = true
    else
        arg.split(/[\s+=]+/).each { |term| addend_strs << term }
    end
end
addend_strs = [ 'send', 'more', 'money' ] if (addend_strs.empty?)
sum_str = addend_strs.pop

#
# Split the strings up into their component letters; create some (ugly) code to
# eventually print out a nice table of the addition.
#
table_print_code = 'print " '
(sum_str.length - 1).downto(1) do |i|
    table_print_code << "   \#{carry#{i}}"
end
table_print_code << "\\n\"\n"
addends = [ ]
first_letters = { }
(0...addend_strs.size).each do |i|
    addend_str = addend_strs[i]
    addend_chars = addend_str.split(//).reverse
    addends << addend_chars
    first_letters[addend_chars[-1]] = 1
    table_print_code \
      << 'print "' << ((i < addend_strs.size - 1)? ' ' : '+') \
      << '    ' * (sum_str.length - addend_str.length) \
      << addend_str.gsub(/([a-z])/, ' \1:#{\1}') << "\\n\"\n"
end
table_print_code \
  << 'print "-' << ('----' * sum_str.length) << "\\n\"\n" \
  << 'print " ' << sum_str.gsub(/([a-z])/, ' \1:#{\1}') << "\\n\"\n"
sum_chars = sum_str.split(//).reverse
first_letters[sum_chars[-1]] = 1

#
# Build the addition code.
#
# This, too, is quite ugly and I don't bother to document it, as printing out
# the generated code will probably give one a better idea of how it works than
# my usual verbose documentation (i.e., run this script with -v).
#
seen_chars = { }
code_head = "rem_digs = (0..9).to_a\n"
code_tail = ''
answer_print_code = 'print "'
indent = ''
(0...sum_chars.size).each do |col|
    sum_char = sum_chars[col]
    col_sum_code = "#{indent}carry#{col+1}, #{sum_char} = (carry#{col}"
    addends.inject([ ]) { |dc, addend| dc << addend[col] }.each do |dig_char|
        next if (dig_char.nil?)
        if (seen_chars[dig_char].nil?)
            code_head << "#{indent}rem_digs.unmarkeds do |#{dig_char}|\n"
            code_tail[0,0] = "#{indent}end\n"
            indent << '   '
            seen_chars[dig_char] = 1
            code_head << "#{indent}next if (#{dig_char} == 0)  # leading 0?\n" \
              if (first_letters.has_key?(dig_char))
            col_sum_code[0,0] = '   '   # fix indentation
            answer_print_code << ", #{dig_char} = \#{#{dig_char}}"
        end
        col_sum_code << " + #{dig_char}"
    end
    col_sum_code << ").divmod(10)\n"
    col_sum_code.sub!(/\(carry0 \+ /, '(')
    if (seen_chars[sum_char].nil?)
        code_head << col_sum_code
        code_head << "#{indent}next if (#{sum_char} == 0)  # leading 0?\n" \
          if (first_letters.has_key?(sum_char))
        code_head << "#{indent}rem_digs.if_unmarked(#{sum_char}) do\n"
        code_tail[0,0] = "#{indent}end\n"
        indent << '   '
        seen_chars[sum_char] = 1
        answer_print_code << ", #{sum_char} = \#{#{sum_char}}"
    else
        col_sum_code.sub!(/ = /, '2 = ')
        code_head \
          << col_sum_code \
          << "#{indent}next unless (#{sum_char}2 == #{sum_char})  # inconsistent?\n"
    end
end
answer_print_code.sub!(/\", /, '"\n')
answer_print_code << "\\n\"\n"

#
# And print out the code (if verbose) and run it!
#
code = code_head + answer_print_code + table_print_code + code_tail
print code, "\n" if (verbose)
eval(code)

In This Thread