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


Groups > comp.os.linux.advocacy > #383512

Re: Where are you, sdb? I have something fun for your little morons to try

From deplorable owl <owl@rooftop.invalid>
Newsgroups comp.os.linux.advocacy
Subject Re: Where are you, sdb? I have something fun for your little morons to try
Date 2016-12-10 05:24 +0000
Organization O.W.L.
Message-ID <hgjdu9x83.g4a@rooftop.invalid> (permalink)
References <o29gns$89o$2@dont-email.me> <20161209033817.6653501a@maxa-pc> <hgdos9893.g@rooftop.invalid> <20161210003352.7436a0f1@maxa-pc>

Show all headers | View raw


Melzzzzz <mel@zzzzz.com> wrote:
> 
> Try to generate then sort ;p
> 
> [bmaxa@maxa-pc hello]$ time ./date_sort 
> 93172 unique dates
> 
> 03-Jan-0030
> 05-Jan-0030
> 11-Jan-0030
> 14-Jan-0030
> 16-Jan-0030
> 23-Jan-0030
> 28-Jan-0030
> 31-Jan-0030
> 07-Feb-0030
> 09-Feb-0030
> 
> 25-Oct-2015
> 01-Nov-2015
> 05-Nov-2015
> 15-Nov-2015
> 22-Nov-2015
> 24-Nov-2015
> 01-Dec-2015
> 27-Dec-2015
> 28-Dec-2015
> 30-Dec-2015
> 
> 
> real    0m0.344s
> user    0m0.417s
> sys     0m0.010s
> [bmaxa@maxa-pc hello]$ cat date_sort.go
> package main 
> 
...
Here's how yours runs on my machine:
anon@lowtide:~/code/dfsdates$ time ./date_sort
93184 unique dates

22-Jan-0030
24-Jan-0030
26-Jan-0030
28-Jan-0030
09-Feb-0030
11-Feb-0030
12-Feb-0030
28-Feb-0030
08-Mar-0030
15-Mar-0030

17-Oct-2015
31-Oct-2015
02-Nov-2015
06-Nov-2015
13-Nov-2015
27-Nov-2015
29-Nov-2015
01-Dec-2015
08-Dec-2015
14-Dec-2015


real    0m0.719s
user    0m0.700s
sys     0m0.016s
anon@lowtide:~/code/dfsdates$ 

Melzzz you are evil.
DAMN those randoms!.  86400 seconds per day and 100,000 days!  Here's my
attempt at it (There's probably some dupes in there somewhere, but
I'm just stabbing in the dark.  I'm sure you probably know a better
C approach).

anon@lowtide:~/code/dfsdates$ time ./glah
---------------------------------
unsorted:

rannum[0]: 0: 31-Dec-1969
rannum[1]: 5673506200: 14-Oct-2149
rannum[2]: -3422670840: 16-Jul-1861
rannum[3]: 1639072836: 09-Dec-2021
rannum[4]: 633999516: 02-Feb-1990
...
rannum[99995]: 612173732: 26-May-1989
rannum[99996]: 681534972: 06-Aug-1991
rannum[99997]: -166082715: 26-Sep-1964
rannum[99998]: 0: 31-Dec-1969
rannum[99999]: 4202178830: 01-Mar-2103
---------------------------------
sorted:

rannum[0]: -8587301344: 16-Nov-1697
rannum[1]: -8586063768: 01-Dec-1697
rannum[2]: -8584082936: 23-Dec-1697
rannum[3]: -8581681672: 20-Jan-1698
rannum[4]: -8581265688: 25-Jan-1698
...
rannum[99995]: 8585401864: 22-Jan-2242
rannum[99996]: 8586649096: 06-Feb-2242
rannum[99997]: 8586863576: 08-Feb-2242
rannum[99998]: 8588090632: 22-Feb-2242
rannum[99999]: 8589213816: 07-Mar-2242

real    0m0.021s
user    0m0.020s
sys     0m0.000s
anon@lowtide:~/code/dfsdates$ 

glah.c:
---------------------------------------------------------------
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <limits.h>

struct mdy {
  int d;
  int m;
  int y; 
};

long getints(struct mdy *, char *);
int compar(const void *,const void *);
int printarray(int64_t *,int);

int main(int argc, char *argv[])
{
  long i=0;

int64_t rannum[100000];
srandom(time(NULL)+getpid());

for(i=0;i<100000;i++)
{
  rannum[i]=random()%INT_MAX+(-INT_MAX/2);
  rannum[i]*=random()%9;
}
printf("---------------------------------\n");
printf("unsorted:\n");
printf("\n");
printf("sorted:\n");
printarray(rannum,0);
printarray(rannum,1);
printarray(rannum,2);
printarray(rannum,3);
printarray(rannum,4);
printf("...\n");
printarray(rannum,99995);
printarray(rannum,99996);
printarray(rannum,99997);
printarray(rannum,99998);
printarray(rannum,99999);

  qsort(rannum,100000,sizeof(long long),compar);

printf("---------------------------------\n");
printf("sorted:\n");
printf("\n");
printarray(rannum,0);
printarray(rannum,1);
printarray(rannum,2);
printarray(rannum,3);
printarray(rannum,4);
printf("...\n");
printarray(rannum,99995);
printarray(rannum,99996);
printarray(rannum,99997);
printarray(rannum,99998);
printarray(rannum,99999);

  return 0; 
}

long getints(struct mdy *themdy, char *str)
{
  char *months[]={"Jan","Feb","Mar","Apr","May","Jun",
                  "Jul","Aug","Sep","Oct","Nov","Dec"};
  char *token;
  char *delim="-";
  int i=0;
  int j=0;
  char arr[12]={0};
  strcpy(arr,str);
  token=strtok(arr,delim);
  themdy->d=atoi(token);  
  while(token!=NULL)
  {
    i++;
    token=strtok(NULL,delim);
    if(i==1)
    {
       for(j=0;j<12;j++)
       {
         if( !strcmp(token,months[j]) )
         {
            themdy->m=j; 
         }
       } 
    }
    if(i==2)
    {
      themdy->y=atoi(token);
    } 
  }
  return 0;
}

int compar(const void *a,const void *b)
{
  if( *(long long *)a < *(long long *)b)
  {
    return -1;
  } 
  else if( *(long long *)a > *(long long *)b)
  {
    return 1;
  }
  else
  {
    return 0;
  }
}

int printarray(int64_t *rannum,int x)
{
  char buf[100]={0};
  
printf("rannum[%d]: %lld: ",x,(long long)rannum[x]);
  strftime(buf,sizeof buf,"%d-%b-%Y",
           localtime((time_t *)&rannum[x]));
  printf("%s\n",buf);
return 0;
}
---------------------------------------------------------------

Back to comp.os.linux.advocacy | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-07 12:27 -0500
  Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-07 19:52 +0000
    Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-07 21:28 -0500
      Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-08 05:52 +0000
        Re: Where are you, sdb? I have something fun for your little morons to try chrisv <chrisv@nospam.invalid> - 2016-12-08 07:02 -0600
          Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 09:02 -0500
  Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 00:32 +0000
    Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-07 21:48 -0500
      Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 14:17 +0000
        Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 11:00 -0500
          Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-08 09:13 -0800
            Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 18:41 -0500
              Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-08 17:32 -0800
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 21:12 -0500
                Cartoons are easier to read than the Wall Street Journal. Jeff-Relf.Me <@.> - 2016-12-08 20:16 -0800
                Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-09 09:03 -0800
      Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 15:49 +0000
        Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 11:00 -0500
          Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 16:24 +0000
            Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 18:43 -0500
              Only _results_ matter; i.e.:  What does it do ? Jeff-Relf.Me <@.> - 2016-12-08 19:45 -0800
                Re: Only _results_ matter; i.e.:  What does it do ? flatfish+++ <flatfish@linuxmail.org> - 2016-12-08 22:50 -0500
                I don't need the source code. Jeff-Relf.Me <@.> - 2016-12-08 20:39 -0800
                Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-08 23:48 -0500
                I'm hard to copy, thank God. Jeff-Relf.Me <@.> - 2016-12-08 22:30 -0800
                Re: I'm hard to copy, thank God. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 01:54 -0500
                Re: I'm hard to copy, thank God. Steve Carroll <fretwizzer@gmail.com> - 2016-12-09 12:30 -0800
                Re: I don't need the source code. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 07:12 +0100
                Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 01:15 -0500
                Re: I don't need the source code. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 07:27 +0100
                Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 01:44 -0500
                Usenet is not CraigsList nor WikiPedia, Reddit. Jeff-Relf.Me <@.> - 2016-12-08 23:00 -0800
                Re: Usenet is not CraigsList nor WikiPedia, Reddit. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 02:12 -0500
                If/When Cola is being honest, they don't think MicroSoft is "Evil". Jeff-Relf.Me <@.> - 2016-12-08 23:56 -0800
                Re: Usenet is not CraigsList nor WikiPedia, Reddit. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 08:16 +0100
                Usually, the __DEFAULT__ "Subject:" line isn't best. Jeff-Relf.Me <@.> - 2016-12-08 22:53 -0800
                Re: Usually, the __DEFAULT__ "Subject:" line isn't best. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 08:19 +0100
                Please lookup the word "Default". Jeff-Relf.Me <@.> - 2016-12-08 23:31 -0800
                Re: Please lookup the word "Default". Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 08:42 +0100
                The parent post. -- Re: Please lookup the word "Default". Jeff-Relf.Me <@.> - 2016-12-09 00:12 -0800
                Re: The parent post. -- Re: Please lookup the word "Default". Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 11:28 +0100
                Threads branch like a tree, SubTopics sprout. Jeff-Relf.Me <@.> - 2016-12-09 03:35 -0800
                Re: Threads branch like a tree, SubTopics sprout. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 16:18 +0100
                Re: The parent post. -- Re: Please lookup the word "Default". moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-09 15:05 +0000
                I want details, Michael Moroney. Jeff-Relf.Me <@.> - 2016-12-09 07:18 -0800
                Re: I want details, Michael Moroney. Steve Carroll <fretwizzer@gmail.com> - 2016-12-09 10:38 -0800
                Re: I want details, Michael Moroney. moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-10 04:03 +0000
                I never had to deal with such problems. Jeff-Relf.Me <@.> - 2016-12-09 21:15 -0800
                Re: I never had to deal with such problems. moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-11 01:50 +0000
                Re: The parent post. -- Re: Please lookup the word "Default". chrisv <chrisv@nospam.invalid> - 2016-12-09 09:37 -0600
                Re: The parent post. -- Re: Please lookup the word "Default". moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-09 20:32 +0000
                Re: I don't need the source code. chrisv <chrisv@nospam.invalid> - 2016-12-09 06:39 -0600
                Re: I don't need the source code. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 16:19 +0100
                Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-09 11:51 -0500
                Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 12:07 -0500
                Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-09 12:22 -0500
                Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 12:28 -0500
                Re: I don't need the source code. moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-09 17:52 +0000
                I only have time to read a few select authors, sorry. Jeff-Relf.Me <@.> - 2016-12-09 10:05 -0800
                Re: I don't need the source code. chrisv <chrisv@nospam.invalid> - 2016-12-09 12:26 -0600
                Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-09 14:06 -0500
                Re: I don't need the source code. Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-12-09 19:56 -0500
                Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-10 09:23 -0500
                Re: Only _results_ matter; i.e.:  What does it do ? fr314159@gmail.com - 2016-12-09 07:17 -0800
                Re: Only _results_ matter; i.e.: What does it do ? DFS <nospam@dfs.com> - 2016-12-12 18:54 -0500
    Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-12 18:39 -0500
  Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-09 03:38 +0100
    Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-09 19:00 +0000
      Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-10 00:33 +0100
        Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 05:24 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-10 06:54 +0100
            Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 06:25 +0000
              Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-10 07:28 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:56 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 15:19 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 15:23 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 20:44 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 17:55 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 00:02 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 19:39 -0500
                C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's. Jeff-Relf.Me <@.> - 2016-12-10 23:09 -0800
                Re: C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's. deplorable owl <owl@rooftop.invalid> - 2016-12-11 07:23 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 19:56 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 20:07 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 04:07 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-11 00:18 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-11 03:40 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 04:00 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 05:08 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 04:27 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 05:58 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 05:55 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 07:11 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 06:49 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-11 07:52 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 07:09 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 08:23 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 07:37 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 08:40 +0100
                Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 09:05 +0000
        Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:41 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-10 20:48 +0100
            Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 20:06 +0000
      Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 10:32 -0500
        Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-10 16:40 +0100
          Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 11:03 -0500
            Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-10 09:26 -0800
              Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 12:38 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-10 09:52 -0800
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 13:01 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-10 10:06 -0800
            Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:38 +0000
              Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 19:55 -0500
        Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:33 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 20:00 +0000

csiph-web