The Ruby Game

## the question is can you write the fastest or shortest code?
## do you dare to take on your peers in a game of speed?

Viewing Submission

submitted by darkphnx
on December 11th, 2013 10:49

0

Distressed Ducks

This page shows a submission for this challenge. The code below shows what was submitted with the results and timing information. You can also see this submissions current position in the challenge scoreboard.

  • When we tested this code it Succeeded!
  • This code runs in 6.898606s
Input Output Duration Status
"2013-12-06 23:41:54, 2013-12-06 23:42:04, 2013-12-06 23:42:14, 2013-12-06 23:42:32, 2013-12-06 23:42:47, 2013-12-06 23:42:51, 2013-12-06 23:43:05, 2013-12-06 23:43:10, 2013-12-06 23:43:14, 2013-12-06 23:43:15, 2013-12-06 23:43:32, 2013-12-06 23:43:43, 2013-12-06 23:43:50, 2013-12-06 23:44:02, 2013-12-06 23:44:14, 2013-12-06 23:44:18, 2013-12-06 23:44:35, 2013-12-06 23:44:40, 2013-12-06 23:44:52, 2013-12-06 23:44:55, 2013-12-06 23:45:02, 2013-12-06 23:45:04, 2013-12-06 23:45:05, 2013-12-06 23:45:07, 2013-12-06 23:45:09, 2013-12-06 23:45:10, 2013-12-06 23:45:26, 2013-12-06 23:45:34, 2013-12-06 23:45:47, 2013-12-06 23:46:02, 2013-12-06 23:46:03, 2013-12-06 23:46:18, 2013-12-06 23:46:34, 2013-12-06 23:46:50, 2013-12-06 23:47:09, 2013-12-06 23:47:21, 2013-12-06 23:47:22, 2013-12-06 23:47:35, 2013-12-06 23:47:50, 2013-12-06 23:47:55, 2013-12-06 23:48:06, 2013-12-06 23:48:24, 2013-12-06 23:48:42, 2013-12-06 23:48:55, 2013-12-06 23:48:55, 2013-12-06 23:49:08, 2013-12-06 23:49:08, 2013-12-06 23:49:24, 2013-12-06 23:49:30, 2013-12-06 23:49:41, 2013-12-06 23:49:59, 2013-12-06 23:50:13, 2013-12-06 23:50:15, 2013-12-06 23:50:28, 2013-12-06 23:50:44, 2013-12-06 23:50:46, 2013-12-06 23:50:51, 2013-12-06 23:51:10, 2013-12-06 23:51:18, 2013-12-06 23:51:22, 2013-12-06 23:51:26, 2013-12-06 23:51:41, 2013-12-06 23:51:55, 2013-12-06 23:51:59, 2013-12-06 23:52:06, 2013-12-06 23:52:17, 2013-12-06 23:52:31, 2013-12-06 23:52:39, 2013-12-06 23:52:44, 2013-12-06 23:53:03, 2013-12-06 23:53:03, 2013-12-06 23:53:07, 2013-12-06 23:53:24, 2013-12-06 23:53:25, 2013-12-06 23:53:38, 2013-12-06 23:53:39, 2013-12-06 23:53:58, 2013-12-06 23:54:17, 2013-12-06 23:54:25, 2013-12-06 23:54:30, 2013-12-06 23:54:49, 2013-12-06 23:55:03, 2013-12-06 23:55:04, 2013-12-06 23:55:15, 2013-12-06 23:55:34, 2013-12-06 23:55:47, 2013-12-06 23:55:54, 2013-12-06 23:56:12, 2013-12-06 23:56:13, 2013-12-06 23:56:13, 2013-12-06 23:56:19, 2013-12-06 23:56:19, 2013-12-06 23:56:38, 2013-12-06 23:56:41, 2013-12-06 23:56:44, 2013-12-06 23:56:57, 2013-12-06 23:56:58, 2013-12-06 23:57:05, 2013-12-06 23:57:10, 2013-12-06 23:57:15, 2013-12-06 23:57:22, 2013-12-06 23:57:23, 2013-12-06 23:57:35, 2013-12-06 23:57:37, 2013-12-06 23:57:47, 2013-12-06 23:57:59, 2013-12-06 23:58:17, 2013-12-06 23:58:17, 2013-12-06 23:58:29, 2013-12-06 23:58:39, 2013-12-06 23:58:56, 2013-12-06 23:58:56, 2013-12-06 23:59:05, 2013-12-06 23:59:08, 2013-12-06 23:59:27, 2013-12-06 23:59:56, 2013-12-06 23:59:58, 2013-12-06 23:59:59, 2013-12-07 00:00:01, 2013-12-07 00:00:02, 2013-12-07 00:00:04, 2013-12-07 00:00:05, 2013-12-07 00:00:35, 2013-12-07 00:00:50, 2013-12-07 00:01:02, 2013-12-07 00:01:16, 2013-12-07 00:01:24, 2013-12-07 00:01:37, 2013-12-07 00:01:41, 2013-12-07 00:01:41, 2013-12-07 00:01:51, 2013-12-07 00:01:54, 2013-12-07 00:02:10, 2013-12-07 00:02:12, 2013-12-07 00:02:23, 2013-12-07 00:02:24, 2013-12-07 00:02:25, 2013-12-07 00:02:26, 2013-12-07 00:02:44, 2013-12-07 00:03:00, 2013-12-07 00:03:10, 2013-12-07 00:03:26, 2013-12-07 00:03:27, 2013-12-07 00:03:37, 2013-12-07 00:03:53, 2013-12-07 00:04:02, 2013-12-07 00:04:17, 2013-12-07 00:04:34, 2013-12-07 00:04:48, 2013-12-07 00:05:05, 2013-12-07 00:05:11, 2013-12-07 00:05:22, 2013-12-07 00:05:23, 2013-12-07 00:05:37, 2013-12-07 00:05:52, 2013-12-07 00:06:08, 2013-12-07 00:06:25, 2013-12-07 00:06:27, 2013-12-07 00:06:42, 2013-12-07 00:06:53, 2013-12-07 00:06:59, 2013-12-07 00:07:05, 2013-12-07 00:07:06, 2013-12-07 00:07:09, 2013-12-07 00:07:25, 2013-12-07 00:07:26, 2013-12-07 00:07:38, 2013-12-07 00:07:51, 2013-12-07 00:08:05, 2013-12-07 00:08:13, 2013-12-07 00:08:31, 2013-12-07 00:08:37, 2013-12-07 00:08:48, 2013-12-07 00:09:02, 2013-12-07 00:09:05, 2013-12-07 00:09:07, 2013-12-07 00:09:16, 2013-12-07 00:09:20, 2013-12-07 00:09:25, 2013-12-07 00:09:34, 2013-12-07 00:09:47, 2013-12-07 00:10:05, 2013-12-07 00:10:14, 2013-12-07 00:10:19, 2013-12-07 00:10:25, 2013-12-07 00:10:39, 2013-12-07 00:10:56, 2013-12-07 00:11:14, 2013-12-07 00:11:33, 2013-12-07 00:11:44, 2013-12-07 00:11:45, 2013-12-07 00:11:53, 2013-12-07 00:12:08, 2013-12-07 00:12:08, 2013-12-07 00:12:23, 2013-12-07 00:12:30, 2013-12-07 00:12:48, 2013-12-07 00:13:07, 2013-12-07 00:13:13, 2013-12-07 00:13:22, 2013-12-07 00:13:29, 2013-12-07 00:13:33, 2013-12-07 00:13:44, 2013-12-07 00:13:55, 2013-12-07 00:14:09" 7 3.502263s
Passed
"2013-12-07 01:28:56, 2013-12-07 01:29:10, 2013-12-07 01:29:11, 2013-12-07 01:29:12, 2013-12-07 01:29:16, 2013-12-07 01:29:31, 2013-12-07 01:29:33, 2013-12-07 01:29:36, 2013-12-07 01:29:52, 2013-12-07 01:30:04, 2013-12-07 01:30:16, 2013-12-07 01:30:21, 2013-12-07 01:30:22, 2013-12-07 01:30:24, 2013-12-07 01:30:26, 2013-12-07 01:30:31, 2013-12-07 01:30:49, 2013-12-07 01:30:52, 2013-12-07 01:30:58, 2013-12-07 01:31:04, 2013-12-07 01:31:04, 2013-12-07 01:31:10, 2013-12-07 01:31:16, 2013-12-07 01:31:29, 2013-12-07 01:31:36, 2013-12-07 01:31:37, 2013-12-07 01:31:55, 2013-12-07 01:32:01, 2013-12-07 01:32:07, 2013-12-07 01:32:09, 2013-12-07 01:32:12, 2013-12-07 01:32:21, 2013-12-07 01:32:35, 2013-12-07 01:32:52, 2013-12-07 01:33:01, 2013-12-07 01:33:18, 2013-12-07 01:33:37, 2013-12-07 01:33:40, 2013-12-07 01:33:41, 2013-12-07 01:33:44, 2013-12-07 01:33:55, 2013-12-07 01:33:55, 2013-12-07 01:34:07, 2013-12-07 01:34:20, 2013-12-07 01:34:21, 2013-12-07 01:34:30, 2013-12-07 01:34:31, 2013-12-07 01:34:38, 2013-12-07 01:34:56, 2013-12-07 01:35:13, 2013-12-07 01:35:13, 2013-12-07 01:35:19, 2013-12-07 01:35:33, 2013-12-07 01:35:34, 2013-12-07 01:35:46, 2013-12-07 01:36:02, 2013-12-07 01:36:06, 2013-12-07 01:36:21, 2013-12-07 01:36:26, 2013-12-07 01:36:43, 2013-12-07 01:37:01, 2013-12-07 01:37:09, 2013-12-07 01:37:24, 2013-12-07 01:37:33, 2013-12-07 01:37:43, 2013-12-07 01:37:48, 2013-12-07 01:37:51, 2013-12-07 01:37:57, 2013-12-07 01:38:04, 2013-12-07 01:38:20, 2013-12-07 01:38:36, 2013-12-07 01:38:47, 2013-12-07 01:39:01, 2013-12-07 01:39:14, 2013-12-07 01:39:31, 2013-12-07 01:39:34, 2013-12-07 01:39:52, 2013-12-07 01:40:02, 2013-12-07 01:40:17, 2013-12-07 01:40:28, 2013-12-07 01:40:34, 2013-12-07 01:40:38, 2013-12-07 01:40:53, 2013-12-07 01:41:02, 2013-12-07 01:41:08, 2013-12-07 01:41:13, 2013-12-07 01:41:15, 2013-12-07 01:41:26, 2013-12-07 01:41:40, 2013-12-07 01:41:48, 2013-12-07 01:42:01, 2013-12-07 01:42:01, 2013-12-07 01:42:09, 2013-12-07 01:42:21, 2013-12-07 01:42:33, 2013-12-07 01:42:41, 2013-12-07 01:42:44, 2013-12-07 01:42:46, 2013-12-07 01:42:59, 2013-12-07 01:43:16, 2013-12-07 01:43:20, 2013-12-07 01:43:26, 2013-12-07 01:43:43, 2013-12-07 01:44:02, 2013-12-07 01:44:03, 2013-12-07 01:44:05, 2013-12-07 01:44:21, 2013-12-07 01:44:23, 2013-12-07 01:44:34, 2013-12-07 01:44:46, 2013-12-07 01:44:46, 2013-12-07 01:45:01, 2013-12-07 01:45:19, 2013-12-07 01:45:23, 2013-12-07 01:45:41, 2013-12-07 01:45:42, 2013-12-07 01:45:56, 2013-12-07 01:46:13, 2013-12-07 01:46:21, 2013-12-07 01:46:40, 2013-12-07 01:46:52, 2013-12-07 01:47:07, 2013-12-07 01:47:07, 2013-12-07 01:47:26, 2013-12-07 01:47:44, 2013-12-07 01:48:01, 2013-12-07 01:48:12, 2013-12-07 01:48:22, 2013-12-07 01:48:33, 2013-12-07 01:48:47, 2013-12-07 01:49:04, 2013-12-07 01:49:10, 2013-12-07 01:49:15, 2013-12-07 01:49:29, 2013-12-07 01:49:30, 2013-12-07 01:49:45, 2013-12-07 01:49:56, 2013-12-07 01:50:07, 2013-12-07 01:50:20, 2013-12-07 01:50:37, 2013-12-07 01:50:40, 2013-12-07 01:50:40, 2013-12-07 01:50:45, 2013-12-07 01:50:59, 2013-12-07 01:51:06, 2013-12-07 01:51:12, 2013-12-07 01:51:13, 2013-12-07 01:51:14, 2013-12-07 01:51:15, 2013-12-07 01:51:17, 2013-12-07 01:51:19, 2013-12-07 01:51:51, 2013-12-07 01:51:53, 2013-12-07 01:52:07, 2013-12-07 01:52:18, 2013-12-07 01:52:26, 2013-12-07 01:52:33, 2013-12-07 01:52:45, 2013-12-07 01:52:59, 2013-12-07 01:53:03, 2013-12-07 01:53:16, 2013-12-07 01:53:20, 2013-12-07 01:53:30, 2013-12-07 01:53:48, 2013-12-07 01:53:49, 2013-12-07 01:54:01, 2013-12-07 01:54:18, 2013-12-07 01:54:18, 2013-12-07 01:54:25, 2013-12-07 01:54:29, 2013-12-07 01:54:40, 2013-12-07 01:54:42, 2013-12-07 01:54:54, 2013-12-07 01:55:09, 2013-12-07 01:55:16, 2013-12-07 01:55:25, 2013-12-07 01:55:41, 2013-12-07 01:55:54, 2013-12-07 01:56:08, 2013-12-07 01:56:24, 2013-12-07 01:56:38, 2013-12-07 01:56:43, 2013-12-07 01:56:55, 2013-12-07 01:57:06, 2013-12-07 01:57:21, 2013-12-07 01:57:21, 2013-12-07 01:57:23, 2013-12-07 01:57:33, 2013-12-07 01:57:33, 2013-12-07 01:57:38, 2013-12-07 01:57:46, 2013-12-07 01:57:56, 2013-12-07 01:58:07, 2013-12-07 01:58:20, 2013-12-07 01:58:30, 2013-12-07 01:58:40, 2013-12-07 01:58:59, 2013-12-07 01:59:03, 2013-12-07 01:59:07, 2013-12-07 01:59:15, 2013-12-07 01:59:20" 6 3.396343s
Passed

The Code

require 'time'

longest_streak = 1
all_quacks = quacks.split(', ').map{|t| Time.parse(t)}

this_streak = 1
all_quacks.each_cons(2) do |(quack1, quack2)|
  if (quack2 - quack1) <= 3
    this_streak += 1
  else
    longest_streak = this_streak if this_streak > longest_streak
    this_streak = 1
  end
end
longest_streak = this_streak if this_streak > longest_streak

longest_streak

Sponsors

aTech Media provide development time & hosting resources for this site. Why not check out some of their other things?