Hi,
[For readers who aren't following this thread, this is YOUR SILLY WARNING.]
>What about:
> 0. Amount of time spent coding your solution.
This is (5) Showing off, and clearly merits points.
>I think 3 should be split into 3a time and 3b space - we are not all
>Einsteins, you know!
Although that would simplify email addresses considerably.
Efficiency extremes will be awarded points for showing off, naturally
enough.
---*---
For example, one might consider the permutation repeater for
references. Since references contain one and only one item, the set
of permutations is computationally tractable. Here is an
implementation which does the job.
;;; Example of reasonably efficient solution to permutation problem.
;;; Known Limitation: only handles objects containing a single element
;;; such as refs. Can also handle lists, vectors and strings of length 1.
define permutations_of_ref( ref );
listtopd( [ ^ref ] )
enddefine;
Now, I daresay some (insufficiently silly) people will complain that
"listtopd" needs definition. Fusspots.
;;; OK, OK here it is.
;;; Converts lists to repeaters. The repeaters are pushable.
define listtopd( L ) -> R;
lvars seen_termin = false;
procedure();
if null( L ) then
if seen_termin then
mishap( 'listtopd: repeater exhausted', [] )
else
true -> seen_termin;
termin;
endif
else
fast_destpair( L ) -> L
endif
endprocedure -> R;
procedure( /* item */ ) with_nargs 1;
conspair( /* item */, L ) -> L
endprocedure -> updater( R );
enddefine;
--
Steve
|