[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Jotto jot-matcher



Would using a bit vector be suitable?

$value = 0;
$value ||=  1<<(ord($_)-ord('a')) for (split //, "radar") ;

or

$value = "";
vec($value, ord($_)-ord('a'), 1)=1 for (split //, "radar") ;

Depending if you want to keep it numeric or string.

<chaim>

>>>>> "BC" == Bernie Cosell <bernie@fantasyfarm.com> writes:

BC> Small challenge [only asking here because I'm finding it surprisingly 
BC> difficult to do, and so I'm thinking that I must be overlooking something 
BC> clever]:  Write a boolean subroutine to determine whether a word matches 
BC> a probe/jots result; _fast_ is more important than small.

BC> I figure you can assume that either/both of the words have some kind of 
BC> associated info along with them [that is, neither word need be just a 
BC> string --- e.g., the 'words' could be sorted lists of letters if that 
BC> makes the match faster]

-- 
Chaim Frenkel					     Nonlinear Knowledge, Inc.
chaimf@pobox.com				               +1-718-236-0183

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe