Everybody else is doing it - Ruby Code Golf

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 3758 Views - Last Post: 04 February 2011 - 07:52 PM Rate Topic: -----

#16 T3hC13h  Icon User is offline

  • D.I.C Regular

Reputation: 65
  • View blog
  • Posts: 337
  • Joined: 05-February 08

Re: Everybody else is doing it - Ruby Code Golf

Posted 03 February 2011 - 07:59 PM

View PostDark_Nexus, on 03 February 2011 - 05:05 PM, said:

With some shorthand stolen from previous posts.

28!

Spoiler


Not working :(
Was This Post Helpful? 0
  • +
  • -

#17 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 766
  • View blog
  • Posts: 2,916
  • Joined: 12-May 09

Re: Everybody else is doing it - Ruby Code Golf

Posted 03 February 2011 - 08:00 PM

Odd, it worked for me. What version of ruby are you using?
Was This Post Helpful? 0
  • +
  • -

#18 T3hC13h  Icon User is offline

  • D.I.C Regular

Reputation: 65
  • View blog
  • Posts: 337
  • Joined: 05-February 08

Re: Everybody else is doing it - Ruby Code Golf

Posted 04 February 2011 - 08:23 AM

1.8.7

It runs, but its not returning a correct count. I don't think string.count takes regex.
Was This Post Helpful? 0
  • +
  • -

#19 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 766
  • View blog
  • Posts: 2,916
  • Joined: 12-May 09

Re: Everybody else is doing it - Ruby Code Golf

Posted 04 February 2011 - 09:06 AM

Ah! I think you're right. It doesn't seem to be a regexp but an escape sequence? I just ran it on a file with more whitespace and it didn't handle tabs or newlines.
Was This Post Helpful? 0
  • +
  • -

#20 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1189
  • View blog
  • Posts: 4,590
  • Joined: 02-May 04

Re: Everybody else is doing it - Ruby Code Golf

Posted 04 February 2011 - 05:57 PM

Interesting. I can't find any documentation anywhere that says \s is an escape sequence. It is only counting non spaces though, not all white space.

This post has been edited by Dark_Nexus: 04 February 2011 - 05:57 PM

Was This Post Helpful? 0
  • +
  • -

#21 owlgorithm  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 04-February 11

Re: Everybody else is doing it - Ruby Code Golf

Posted 04 February 2011 - 07:52 PM

My solution may be considered cheating, but it's written in perfectly valid Ruby and runs from the shell invocation "ruby golf.rb" on Snow Leopard. It does give an answer of 24, though ;-)

Spoiler


Otherwise, the best I've been able to do is 28 using Ruby alone, using the following:

Spoiler

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2