Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: One for the weekend: (provisional results)

by BrowserUk (Pope)
on Jun 04, 2008 at 14:45 UTC ( #690152=note: print w/ replies, xml ) Need Help??


in reply to One for the weekend: challenge

I'm not antisipating any late entries, so here are provisional findings on the challenge. Final scoring will require me to write up some kind of assessment of the entries and may take a few days, if it gets done at all. (Anyone really interested?)

The program that generates these will be posted below. As will my original attempt (labelled:BrowserUk below). (Update: Corrected score calculations!)

c:\test\685390>685390.plt Testing Anonymonk1-2 Testing Anonymonk1-reworked Testing Anonymonk1 Testing BrowserUk Testing BrowserUk2 Testing BrowserUk3 Testing karavelov Testing kyle Testing kyle2 Testing LimbicRegion2 Testing LimbicRegion3 { Anonymonk1 =>{ ELAPSED=> 1.64, LOC=> 15, OUTCOUNT=> 262, SCORE=> 2 +4.6 }, Anonymonk1-2 =>{ ELAPSED=> 1.48, LOC=> 12, OUTCOUNT=> 262, SCORE=> 1 +7.76 }, Anonymonk1-rw =>{ ELAPSED=> 1.93, LOC=> 27, OUTCOUNT=> 262, SCORE=> 5 +2.11 }, BrowserUk =>{ ELAPSED=>10.57, LOC=> 36, OUTCOUNT=> 262, SCORE=> 38 +0.52 }, BrowserUk2 =>{ ELAPSED=> 2.07, LOC=> 28, OUTCOUNT=> 262, SCORE=> 5 +7.96 }, BrowserUk3 =>{ ELAPSED=> 1.67, LOC=> 49, OUTCOUNT=> 89, SCORE > 8 +1.83 }, LimbicRegion2 =>{ ELAPSED=>11.03, LOC=> 40, OUTCOUNT=> 262, SCORE=> 44 +1.2 }, LimbicRegion3 =>{ ELAPSED=>12.04, LOC=> 63, OUTCOUNT=> 262, SCORE=> 75 +8.52 }, karavelov =>{ ELAPSED=> 5.08, LOC=> 63, OUTCOUNT=> 262, SCORE=> 32 +0.04 }, kyle =>{ ELAPSED=> 4.69, LOC=> 79, OUTCOUNT=> 262, SCORE=> 37 +0.51 }, kyle2 =>{ ELAPSED=> 2.98, LOC=> 73, OUTCOUNT=> 262, SCORE=> 21 +7.54 }, }

(*)manually compacted to comply with the pathetic wrap ilmit. Anybody would think this was the 1970s!

Ignore, BrowserUk2, BrowserUk3 and Anonymonk1-reworked.

  • BrowserUk2 is my attempt to clean up my own entry once I saw the performance of other peoples solutions.

    It must be discounted because it was too influenced by the work of others.

  • BrowserUk3 is my second attempt at clean up avoiding the influence of others.

    A work in progress and currently non-complient.

  • Anonymonk1-reworked is my attempt to sanitize anonymonk's first entry for 'maintanence purposes'.

    This may get posted as part of a further post discussing that subject.

  • The others above are as posted in this thread.

    Kyle is kyle's entry prior to his updates. kyle2 post-updates.

Test program:

My pre-challenge solution, warts an all. It took less than 1 hour to program a recursive solution that found all possible encodings. Another ~2 hours to hack it to fulfill the specs arbitrary limitations:

  1. No adjacent digits.
  2. No digit where a word is available (even if the use of that word does not result in a successful encoding).

I was quite pleased with the LOC & timings, relative to the information available for the Lisp and Java entries.(Until I saw anonymonks entry! :). I was aware it was convoluted and would need refactoring. Hence the attempts above.

#! perl -slw use strict; use List::Util qw[ reduce ]; $a = $b; use constant DICTIONARY => 'dictionary.txt'; my %mappings; reduce{ $mappings{ $_ } = $a for split '', $b; $a + 1; } 0, qw[ e jnq rwx dsy ft am civ bku lop ghz ]; my %dict = map{ $_ => [ $_ ] } 0 .. 9; keys %dict = 300000; open DICT, '<', DICTIONARY or die "${\DICTIONARY}: $!"; while( <DICT> ) { chomp; my $orig = $_; tr[A-Z"/-][a-z]d; #" push @{ $dict{ join '', @mappings{ split '', $_ } } }, $orig; } close DICT; sub encode { my $number = shift; my $start = length( $number ); --$start while $start and not exists $dict{ substr $number, 0, $st +art }; $start = 2 if $start > 1; return @{ $dict{ $number } || [] }, grep !/\d \d/, map { my( $pre, $post ) = unpack "a$_ a*", $number; map{ my $head = $_; map "$head $_", encode( $post ); } @{ $dict{ $pre } || [] }, } $start .. length( $number )-1; } while( <> ) { chomp; my $orig = $_; tr[/-][]d; print "$orig: $_" for encode( $_ ); }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: One for the weekend: (provisional results)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://690152]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2014-12-25 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls