[Tutor] simple random string generator
d at davea.name
Mon Sep 17 23:25:16 CEST 2012
On 09/17/2012 04:09 PM, Matthew Dalrymple wrote:
> thanks for everyone that gave me a hand...i think i got most of the program done... now i just need to time how long it takes to run each anagramSolution functions to see which one is faster...now i think i might have got it done but for some reason both lines are pretty close to the same.... http://pastie.org/4741560 thats my code...could someone let me know if i used time.time right to get accurate timing...to me it looks like it should be right but the one line i think is supposed to increas exponentially
> thanks :)
Did you look for bugs before trying to time it? For example, did you
intend that it test the sizes from 10 thru 195 in steps of 5, or did you
intend from 10 to 100, as you stated in your first post?
Would you care to add a docstring to those functions to indicate what
they're intended to do? i think maybe the anagramSolutionX functions
are supposed to return True if the two strings contain the same letters
(including the same number of duplicates) in an arbitrary order.
Are you interested in faster algorithms for such a comparison? I think
that function could be implemented in two lines of Python, using only
builtin functions. And that includes the def line.
Did you intend to put the timings for anagramSolution2 into solu1, and
the timings for anagramSolution1 into solu2, and thus print them out in
reverse order? it makes it hard to see what difference incremental
changes might make.
More information about the Tutor