1. Start by writing out your name and the name of your (potential?) partner like so:
2. See how many of each of the characters of "LOVES" are in both names (work out the number of leftover characters too for step 4 - N.B. ONLY counting letters, not spaces!):Buffy the Vampire Slayer LOVES larryk
3. Now do the "magical" add-each-pair-of-numbers-to-produce-new-list-and-repeat operation on this list to reduce it to a percentage (i.e. the first number you come to which is lower than 101).L = 2 (1 in slayer, one in larryk) O = 0 V = 1 (1 in vampire) E = 3 (1 each in the, vampire and slayer) S = 1 (1 in slayer)
Update: There is an exception to this. In certain circumstances this can become a neverending loop e.g. 997 -> 1816 -> 997 ad infinitum. In these cases the result is always 100%. Short of coding around to find all dodgy sets and then hard-code to avoid them (sort of defeats the point of golfing it) I have decided to include an arbitrary limit to the number of cycles the op must perform before it is deemed to be "spiraling". You can pick your own number but I would advise not less than 12.2 0 1 3 1 2+0=2 0+1=1 1+3=4 3+1=4 2 1 4 4 2+1=3 1+4=5 4+4=8 3 5 8 3+5=8 5+8=13 (special case: if(>9) separate digits) 8 1 3 8+1=9 1+3=4 9 4 = 94%
4. Take the number of leftover characters (n) and count through the word FLAMES (hence the name) to remove the nth character each time until there is one left (N.B. VERY IMPORTANT: each time you restart the count you must start at the position following the character you just removed - see below):
5. Index the key letter into the hash provided to determine the relationship type.In this example the number of remaining chars is 20... F L A M E S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 remove the L F A M E S 1 2 3 4 now start at A .. 20 remove the F A M E S 1 2 3 4 now start at A .. 17 18 19 20 remove the S A M E 1 2 3 now start at A .. 19 20 remove the M A E 1 now start at E .. 20 remove the A E this is the key
E = enemies
Caveats
FORE!!!
#!perl -l $ARGV[0] = 'Buffy the Vampire Slayer'; $ARGV[1] = 'larryk'; @l = qw/l o v e s/; @f = qw/f l a m e s/; %t = ( f => 'friends', l => 'lovers', a => 'arguers', m => 'marriage material', e => 'enemies', s => 'secret lovers' ); sub g { my@F=@f;($s=join'',@_)=~s/\W//g;@_=map$s=~s/$_//gi,@l;$r=length $s;do{@_=map{split'',$_[$_]+$_[$_+1]}0..$#_-1}until 101>join'', @_;$n=0;splice@F,$n=($r+$n-1)%@F,1 while@F>1;join('',@_),@F } print +(g(@ARGV))[0],"% ",$t{(g(@ARGV))[1]}; __END__ 94% enemies
larryk perl -le "s,,reverse killer,e,y,rifle,lycra,,print"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Golf) FLAMES
by chipmunk (Parson) on Aug 30, 2001 at 20:14 UTC | |
by larryk (Friar) on Aug 31, 2001 at 10:20 UTC | |
|
Re: (Golf) FLAMES
by larryk (Friar) on Aug 30, 2001 at 11:03 UTC | |
|
Re: (Golf) FLAMES
by Anonymous Monk on Aug 30, 2001 at 13:29 UTC | |
by larryk (Friar) on Aug 30, 2001 at 19:42 UTC |