• RSS ZoeAndGavin.com

    • An error has occurred; the feed is probably down. Try again later.
  • Top Posts

  • Advertisements

The answer in Ruby (so far)

a = [1,2,3,5,7,8,9,10,12,13,19,200,900,901,902,903,904,905,1000]
l = a[0]
f = a[0]
z = a.length
i = 0
s = ""
until i == z
  if (a[i]+1 == a[i+1])
    l = a[i+1]
  end
  if (a[i]+1 != a[i+1])
    if f == l
      s = s+"#{f}"
      if i+1 != z
        s = s+","
      end
  end
  if f != l
        s = s+"#{f}=>#{l}"
        if i+1 != z
          s = s+","
        end
    end
    f = a[i+1]
    l = f
  end
  i+=1
end

puts s
Advertisements

Bothness

Apparently numbers can be both odd and even…

If IsNumeric(StreetNumberValue) Then
  If 2 Mod CType(StreetNumberValue, Integer) = 0 Then
    OddEven = "E" 'Even
  Else
    OddEven = "O" 'Odd
  End If
Else
  OddEven = "B" 'Both
End If

As seen here:
http://worsethanfailure.com/Articles/Odd-or-Even-or-Both.aspx

Code Golf – Home On The Range

Home On The Range

It’s as simple as “1 2 3 5 6 8” => “1-3, 5-6, 8.”

The Problem

It’s difficult to spot what’s missing in a long list of numbers if they are just listed one after the other. You can make it easier by organising the numbers into ranges, and that’s exactly what you’re going to do here.

Your program will receive a set of space-separated numbers on stdin, and it will be expected to print a set of ranges on stdout formatted according to the following rules :

  • Numbers which appear sequentially in the input should be grouped with the first number and last number in the sequence separated by a hyphen.
  • Numbers which appear in the input on their own should not be collapsed into a range.
  • Ranges and single numbers in your output should be separated by a comma and a space (“, “), and the list of ranges should end with a full-stop (“.“)

Examples

  • 1 2 3” => “1-3.
  • 1 2 3 5 7 8” => “1-3, 5, 7-8.
  • 1 3 4 5 7” => “1, 3-5, 7.

Other Information

  • Your program will be ran three times with increasingly more numbers.
  • There will be a maximum of 500 numbers given to your program, and the maximum value of an individual number will be 500.
  • The numbers will be given in ascending order.
  • The input to each of the three runs will be different each time you upload an entry.

Open source car

Well, now there is an open source car called c,mm,n here is a short write up on it:

http://www.engadget.com/2007/03/30/open-source-c-mm-n-car-hits-amsterdam/

Not sure that it is the best idea, what happens when the software running under the hood has a bug?

It is also a lot ugly, oh well

http://www.autoindetoekomst.nl/website/

Random Haiku

What the f**k, future?
It’s been over twenty years:
where’s my hover car?!

-drivl.com

Virginia Tech

As the carnage unfolded, eyewitnesses IM’d terrifying firsthand accounts to their friends, some of which appeared on blogs and MySpace within minutes of the shootings. Yet students complained that the first official word they heard about a killer on campus came a full two hours after two students were shot to death in a nearby dorm, just as their suspected attacker opened fire again in an academic building on the other side of campus.

There were two hours between the first two students being shot and the killing spree. It also took two hours for the school to mention that there may be a killer on the loose on campus. This in my mind is not acceptable, not in todays world of computers, cell phones, and school shootings.

The school was also closed in the first month of this school year because there was a killer on the campus. This should have prompted a better way of communicating quickly in the school that there was a problem/disaster.

There is no way that it should take 2 hours, and if it does, that gives the administration more time to warn students and teachers through better means that a simple email that says ‘oh, by the way…‘.

Better gun control, stopping the sale of violent video games, and most of those other “solutions” will not really do much until there is a better way of notifying the people in the University that there is a problem and that they should be weary of something, be it a killer, a natural disaster, or something else that is not easily controllable.

Another thing is, shouldn’t there have been a whole bunch of police on campus? Campus security was already there obviously, but they are not trained to deal with shooters I don’t think. You would have thought that someone would have had the presence of mind to call 911 right when the first shoots were heard, instead of videoing with their cell phones that there were shots being heard. Rather than do that, how about doing something to stop the shooting?

I think that 30 deaths could have been avoided. 3 is more than enough for me. Hell, it could have been stopped before anyone died had they taken his writing serious the first time it was brought up.

Vista

Is a crater in Brazil… It may have helped kill off the dinosaurs