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 joekarma
on December 11th, 2013 18:19

+1

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 9.339401s
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.129495s
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.164554s
Passed
"2013-11-30 23:59:41, 2013-11-30 23:59:45, 2013-11-30 23:59:49, 2013-11-30 23:59:55, 2013-11-30 23:59:58, 2013-12-01 00:00:00, 2013-12-01 00:00:01, 2013-12-01 00:00:02, 2013-12-01 00:00:03, 2013-12-01 00:00:04, 2013-12-01 00:00:06, 2013-12-01 00:00:07, 2013-12-01 00:00:11, 2013-12-01 00:00:11, 2013-12-01 00:00:11, 2013-12-01 00:00:12, 2013-12-01 00:00:15, 2013-12-01 00:00:15, 2013-12-01 00:00:17, 2013-12-01 00:00:18, 2013-12-01 00:00:21, 2013-12-01 00:00:22, 2013-12-01 00:00:28, 2013-12-01 00:00:34, 2013-12-01 00:00:34, 2013-12-01 00:00:34, 2013-12-01 00:00:39, 2013-12-01 00:00:42, 2013-12-01 00:00:44, 2013-12-01 00:00:47, 2013-12-01 00:00:50, 2013-12-01 00:00:53, 2013-12-01 00:00:59, 2013-12-01 00:01:03, 2013-12-01 00:01:03, 2013-12-01 00:01:03, 2013-12-01 00:01:04, 2013-12-01 00:01:05, 2013-12-01 00:01:09, 2013-12-01 00:01:14, 2013-12-01 00:01:15, 2013-12-01 00:01:21, 2013-12-01 00:01:25, 2013-12-01 00:01:27, 2013-12-01 00:01:29, 2013-12-01 00:01:31, 2013-12-01 00:01:36, 2013-12-01 00:01:38, 2013-12-01 00:01:39, 2013-12-01 00:01:44, 2013-12-01 00:01:50, 2013-12-01 00:01:52, 2013-12-01 00:01:56, 2013-12-01 00:01:58, 2013-12-01 00:01:59, 2013-12-01 00:02:05, 2013-12-01 00:02:06, 2013-12-01 00:02:12, 2013-12-01 00:02:13, 2013-12-01 00:02:16, 2013-12-01 00:02:19, 2013-12-01 00:02:22, 2013-12-01 00:02:26, 2013-12-01 00:02:32, 2013-12-01 00:02:33, 2013-12-01 00:02:37, 2013-12-01 00:02:39, 2013-12-01 00:02:43, 2013-12-01 00:02:48, 2013-12-01 00:02:51, 2013-12-01 00:02:55, 2013-12-01 00:02:58, 2013-12-01 00:03:00, 2013-12-01 00:03:00, 2013-12-01 00:03:03, 2013-12-01 00:03:08, 2013-12-01 00:03:14, 2013-12-01 00:03:14, 2013-12-01 00:03:14, 2013-12-01 00:03:15, 2013-12-01 00:03:19, 2013-12-01 00:03:22, 2013-12-01 00:03:27, 2013-12-01 00:03:32, 2013-12-01 00:03:37, 2013-12-01 00:03:40, 2013-12-01 00:03:41, 2013-12-01 00:03:46, 2013-12-01 00:03:51, 2013-12-01 00:03:51, 2013-12-01 00:03:55, 2013-12-01 00:03:55, 2013-12-01 00:03:57, 2013-12-01 00:04:02, 2013-12-01 00:04:08, 2013-12-01 00:04:09, 2013-12-01 00:04:13, 2013-12-01 00:04:13, 2013-12-01 00:04:14, 2013-12-01 00:04:15, 2013-12-01 00:04:18, 2013-12-01 00:04:20, 2013-12-01 00:04:20, 2013-12-01 00:04:22, 2013-12-01 00:04:23, 2013-12-01 00:04:27, 2013-12-01 00:04:28, 2013-12-01 00:04:32, 2013-12-01 00:04:32, 2013-12-01 00:04:37, 2013-12-01 00:04:37, 2013-12-01 00:04:43, 2013-12-01 00:04:44, 2013-12-01 00:04:50, 2013-12-01 00:04:56, 2013-12-01 00:04:59, 2013-12-01 00:05:04, 2013-12-01 00:05:06, 2013-12-01 00:05:08, 2013-12-01 00:05:09, 2013-12-01 00:05:09, 2013-12-01 00:05:12, 2013-12-01 00:05:16, 2013-12-01 00:05:18, 2013-12-01 00:05:18, 2013-12-01 00:05:24, 2013-12-01 00:05:24, 2013-12-01 00:05:24, 2013-12-01 00:05:30, 2013-12-01 00:05:34, 2013-12-01 00:05:38, 2013-12-01 00:05:38, 2013-12-01 00:05:44, 2013-12-01 00:05:46, 2013-12-01 00:05:47, 2013-12-01 00:05:53, 2013-12-01 00:05:53, 2013-12-01 00:05:57, 2013-12-01 00:06:03, 2013-12-01 00:06:09, 2013-12-01 00:06:15, 2013-12-01 00:06:18, 2013-12-01 00:06:20, 2013-12-01 00:06:22, 2013-12-01 00:06:24, 2013-12-01 00:06:28, 2013-12-01 00:06:29, 2013-12-01 00:06:29, 2013-12-01 00:06:30, 2013-12-01 00:06:36, 2013-12-01 00:06:42, 2013-12-01 00:06:46, 2013-12-01 00:06:51, 2013-12-01 00:06:51, 2013-12-01 00:06:54, 2013-12-01 00:06:58, 2013-12-01 00:07:02, 2013-12-01 00:07:06, 2013-12-01 00:07:06, 2013-12-01 00:07:06, 2013-12-01 00:07:12, 2013-12-01 00:07:14, 2013-12-01 00:07:16, 2013-12-01 00:07:20, 2013-12-01 00:07:22, 2013-12-01 00:07:24, 2013-12-01 00:07:30, 2013-12-01 00:07:33, 2013-12-01 00:07:34, 2013-12-01 00:07:34, 2013-12-01 00:07:40, 2013-12-01 00:07:44, 2013-12-01 00:07:50, 2013-12-01 00:07:52, 2013-12-01 00:07:53, 2013-12-01 00:07:58, 2013-12-01 00:08:02, 2013-12-01 00:08:07, 2013-12-01 00:08:11, 2013-12-01 00:08:16, 2013-12-01 00:08:18, 2013-12-01 00:08:20, 2013-12-01 00:08:25, 2013-12-01 00:08:28, 2013-12-01 00:08:30, 2013-12-01 00:08:32, 2013-12-01 00:08:37, 2013-12-01 00:08:42, 2013-12-01 00:08:45, 2013-12-01 00:08:47, 2013-12-01 00:08:50, 2013-12-01 00:08:56, 2013-12-01 00:09:02, 2013-12-01 00:09:04, 2013-12-01 00:09:06, 2013-12-01 00:09:07, 2013-12-01 00:09:11, 2013-12-01 00:09:16, 2013-12-01 00:09:16, 2013-12-01 00:09:20" 8 3.045352s
Passed

The Code

quacks = quacks.split(", ").map { |dt| DateTime.parse(dt) }

quack_streaks = quacks.enum_for(:each_cons, 2).reduce([]) { |runs, quacks|
  difference_in_days = quacks[1] - quacks[0]
  difference_in_seconds = difference_in_days * 24 * 60 * 60
  mere_seconds_apart = difference_in_seconds <= 2
  
  if mere_seconds_apart
    runs[-1] += 1
  else
    runs.push(1)
  end
  
  runs
}.max

Sponsors

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