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.
It must be discounted because it was too influenced by the work of others.
A work in progress and currently non-complient.
This may get posted as part of a further post discussing that subject.
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:
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( $_ ); }
|
|---|