From: Gautam Dey Date: 2006-06-18T05:15:50+09:00 Subject: Re: [QUIZ] Short But Unique (#83) : Clarifications Two things: Are the entries in the array always unique? Or do we have to be able to handle the array such as: ['users_controller', 'users_controller_test', 'account_controller', 'account_controller_test', 'bacon', 'users_controller_test'] Also is the unicode ellipsis counted as one or three characters? -Gautam Dey On Jun 16, 2006, at 5:33 AM, Ruby Quiz wrote: > The three rules of Ruby Quiz: > > 1. Please do not post any solutions or spoiler discussion for this > quiz until > 48 hours have passed from the time on this message. > > 2. Support Ruby Quiz by submitting ideas as often as you can: > > http://www.rubyquiz.com/ > > 3. Enjoy! > > Suggestion: A [QUIZ] in the subject of emails about the problem > helps everyone > on Ruby Talk follow the discussion. Please reply to the original > quiz message, > if you can. > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > =-=-=-=-=-=-= > > by Ryan Williams > > I use Eclipse (with RadRails!) I have a bunch of files open in > tabs. Once enough > files are open, Eclipse starts to truncate the names so that > everything fits. > It truncates them from the right, which means that pretty soon I'm > left unable > to tell which tab is "users_controller.rb" and which is > "users_controller_test.rb", because they're both truncated to > "users_control...". > > The quiz would be to develop an abbrev-like module that shortens a > set of > strings so that they are all within a specified length, and all > unique. You > shorten the strings by replacing a sequence of characters with an > ellipsis > character [U+2026]. If you want it to be ascii-only, use three > periods instead, > but keep in mind that then you can only replace blocks of four or more > characters. > > It might look like this in operation: > > ['users_controller', 'users_controller_test', > 'account_controller', 'account_controller_test', > 'bacon'].compress(10) > => ['users_c...', 'use...test', 'account...', 'acc...test', 'bacon'] > > There's a lot of leeway to vary the algorithm for selecting which > characters to > crop, so extra points go to schemes that yield more readable results. >