Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #147578

Re: So here's a fun challenge

From DFS <nospam@dfs.com>
Subject Re: So here's a fun challenge
Newsgroups comp.lang.c
References <NNgvF.21265$hh5.17108@fx07.iad> <5dbf0295.12592219@core>
Message-ID <s9XvF.7692$522.4454@fx05.iad> (permalink)
Organization blocknews - www.blocknews.net
Date 2019-11-04 10:07 -0500

Show all headers | View raw


On 11/3/2019 12:35 PM, Scott wrote:
> On Sat, 2 Nov 2019 10:53:01 -0400, DFS <nospam@dfs.com> wrote:
> 
>> - create 2 (equal or unequal sized) arrays of random strings of random
>>     lengths from low to high, ie 2 to 4, or 8 to 16, etc
>> - manually add a few of the same values to each array to ensure dupes
>> - print the top and bottom 10 to show initial data set
>> - combine the arrays
>> - case-insensitive sort the arrays (I use qsort but any method is fine)
>> - dedupe the combined array
>> - add the unique vals to a new array that's sized appropriately
>> - print the top and bottom 10 to show final sorted data
> 
> Data points for you - Win10, Intel i5-8600 @3.6GHz. I just copied your
> code (I may attempt my own later):
> 
> randclc 1000000 8 16
> = 1.30 s
> python randclc.py 1000000 8 16
> = 8.61 s (6.62x)
> 
> randclc 10000000 8 16
> = 18.95 s
> python randclc.py 10000000 8 16
> = 95.10 s (5.02x)
> 
> randclc 50000000 8 16
> =  124.19 s
> python randclc.py 50000000 8 16
> =  did not finish:
> Traceback (most recent call last):
>    File "randclc.py", line 9, in <module>
>      randoms1.append(''.join([random.choice(string.ascii_letters +
> string.digits) for x in xrange(random.randint(lo,hi))]))
> MemoryError


I got it to run for 50M elements (I have 8GB memory):

$ python random_strings_clc.py 50000000 8 16
  1. 00001WBS
  2. 0000v7HYK
  3. 0001jWQ9
  4. 0001q2delxg6iUZ
  5. 0002jFMXjtC
  6. 0002lLMqj
  7. 0002LWUk7b
  8. 0002r0jp
  9. 00037hk3a1GD
10. 0003fWNinSq
49999999. ZzzzTXKg9MyrS7
50000000. ZZzZu4ReG4SXdo
50000001. ZZZZuCBAD4CmAh
50000002. zzzzUkuDUaMfl
50000003. ZzZZUlMW7DFE7
50000004. zzZzUSb65
50000005. ZZzzWf7r
50000006. zzzzxQyrk0fIu
50000007. ZZZZy0o2kEtA
50000008. zZZZYsU42
program ran in: 2.26e+03 seconds (37.7 minutes)



> randclc 100000000 8 16
> = 279.29 s
> python randclc.py 100000000 8 16
> = did not attempt
> 
> I don't know enough about Python to say why it errored out. There
> should be plenty of RAM, unless it's using a lot more than I'd guess.


Thanks for the info.  5x to 7x slower than C isn't bad python performance.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-02 10:53 -0400
  Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 17:08 +0000
    Re: So here's a fun challenge Richard Damon <Richard@Damon-Family.org> - 2019-11-02 15:01 -0400
      Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 19:38 +0000
        Re: So here's a fun challenge Richard Damon <Richard@Damon-Family.org> - 2019-11-02 16:07 -0400
        Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:29 -0500
  Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 20:36 +0000
    Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:33 -0500
      Re: So here's a fun challenge Paul <nospam@needed.invalid> - 2019-11-03 20:53 -0500
  Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 14:33 +1300
    Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 14:35 +1300
      Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 00:18 -0400
        Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 18:02 +1300
          Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-03 11:19 +0000
            Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-04 00:33 +1300
          Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:39 -0500
    Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 11:16 +0100
      Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 11:29 +0100
      Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 23:34 +1300
      Re: So here's a fun challenge Melzzzzz <Melzzzzz@zzzzz.com> - 2019-11-03 11:04 +0000
        Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 14:56 +0100
          Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 15:36 +0100
  Re: So here's a fun challenge nobody@example.org (Scott) - 2019-11-03 17:35 +0000
    Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-04 08:03 +1300
    Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-04 10:07 -0500
      Re: So here's a fun challenge nobody@example.org (Scott) - 2019-11-04 16:06 +0000
        Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-04 15:33 -0500

csiph-web