Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #383155 > unrolled thread
| Started by | DFS <nospam@dfs.com> |
|---|---|
| First post | 2016-12-07 12:27 -0500 |
| Last post | 2016-12-10 20:00 +0000 |
| Articles | 20 on this page of 115 — 14 participants |
Back to article view | Back to comp.os.linux.advocacy
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
Page 4 of 6 — ← Prev page 1 2 3 [4] 5 6 Next page →
| From | Silver Slimer <.m@nsn.s> |
|---|---|
| Date | 2016-12-09 14:06 -0500 |
| Subject | Re: I don't need the source code. |
| Message-ID | <o2ev8b$9ih$2@dont-email.me> |
| In reply to | #383439 |
On 2016-12-09 12:52 PM, Michael Moroney wrote: > Poutnik <poutnik4nntp@gmail.com> writes: > >> On 12/09/2016 01:39 PM, chrisv wrote: >>> Poutnik wrote: >>> >>>> Dne 09/12/2016 v 05:39 Jeff-Relf.Me napsal(a): >>> >>> *plonk* >>> >> So what ? > > chrisv likes to publicly plonk anyone who replies to Relf, probably > to discourage them from replying to him and thus make Relf get lonely > and go away. (won't work). I'm not sure if he follows through, he just > responded to me and surely he must have plonked me by now as I have > responded to Relf often. The fact that anyone who uses Eternal September doesn't see Relf's posts at all might also do it. > Relf himself has apparently semi-plonked me. He can't stand common > sense, I guess. I was sincerely insulted when Relf plonked me. I cried for days on end. Either that or it's what I want him to believe. > As I stated before I hang around sci.physics to k00kwatch more than > anything else, so to me Relf is worth reading, for his bizarre physics > and programming ideas. I can't imagine any planet where Relf is worth reading personally.
[toc] | [prev] | [next] | [standalone]
| From | Chris Ahlstrom <OFeem1987@teleworm.us> |
|---|---|
| Date | 2016-12-09 19:56 -0500 |
| Subject | Re: I don't need the source code. |
| Message-ID | <o2fk2n$od7$1@dont-email.me> |
| In reply to | #383439 |
Michael Moroney wrote this copyrighted missive and expects royalties: > "Moron"-ey? If that ain't a troll nym! :-D -- You attempt things that you do not even plan because of your extreme stupidity.
[toc] | [prev] | [next] | [standalone]
| From | Silver Slimer <.m@nsn.s> |
|---|---|
| Date | 2016-12-10 09:23 -0500 |
| Subject | Re: I don't need the source code. |
| Message-ID | <o2h32m$da8$4@dont-email.me> |
| In reply to | #383504 |
On 2016-12-09 7:56 PM, Chris Ahlstrom wrote: > Michael Moroney wrote this copyrighted missive and expects royalties: > >> > > "Moron"-ey? If that ain't a troll nym! :-D So is Ass-Storm. -- Silver Slimer Fingerprint: e58428b2633833a3b0c9bb7e40819166642245b7 Gab.ai: @silverslimer "Turning crap into solid gold since 1979"
[toc] | [prev] | [next] | [standalone]
| From | fr314159@gmail.com |
|---|---|
| Date | 2016-12-09 07:17 -0800 |
| Subject | Re: Only _results_ matter; i.e.: What does it do ? |
| Message-ID | <b498b12e-54b2-4d12-b3fd-9bc985c895c3@googlegroups.com> |
| In reply to | #383360 |
On Thursday, December 8, 2016 at 10:45:59 PM UTC-5, Jeff-Relf.Me wrote: > Only _results_ matter; i.e.: What does it do ? > > How you code, in what language, isn't interesting. > That is exactly fucking correct. As any competent person knows, programming is NOT about coding. Computer programming is primarily a problem solving activity that employs the concepts of computer science to conceive an efficient, and perhaps even elegant, solution. The actual coding is only a SECONDARY concern. In fact, it is a mark of programming naivete to emphasize coding as the primary goal. The dumb-fuck stooge (DFS) only demonstrates his pathetic programming ineptitude when he extolls his ridiculous code snippets, which usually involve only simplistic string manipulations, merely to show off what he foolishly considers a major accomplishment. But the ideas behind his coding schemes are so simplistic and so shoddy as to be downright laughable. A true programmer first analyzes the underlying concepts, selects the most appropriate data structures, and then develops the most efficient and scalable algorithm. Only after this critical groundwork is laid does any consideration of coding begin. But alas, the art of computer programming has fallen by the wayside. The advent of high-level OO languages, such as the junk-shit known as C#/.NET, allows even a totally naïve idiot to be able to produce commercially acceptable code. In fact, most commercial programmers have little or no background in computer science. In today's world of cheap gimmicks and rapid product churn a solid programming expertise is not really necessary.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-12-12 18:54 -0500 |
| Subject | Re: Only _results_ matter; i.e.: What does it do ? |
| Message-ID | <o2nd9l$ijl$3@dont-email.me> |
| In reply to | #383360 |
On 12/8/2016 10:45 PM, Jeff-Relf.Me wrote: > Only _results_ matter; i.e.: What does it do ? > > How you code, in what language, isn't interesting. It is very interesting if you accomplish a result in python in 1/4 the time of C. That's real cost savings to your employer, which should always be a, if not the, top goal.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-12-12 18:39 -0500 |
| Message-ID | <o2ncc8$gjb$1@dont-email.me> |
| In reply to | #383184 |
On 12/7/2016 7:32 PM, Adlbifhr Mjduhgfks wrote:
> On Wed, 07 Dec 2016 12:27:40 -0500, DFS wrote:
>
>>
>> My 5-line solution (python data structures only)
>>
>
> Another dismal dumb-fuck stooge performance.
>
> For every line of python there is a thousand lines of C
> that is created.
>
> Furthermore, he doesn't even understand the computer science
> behind the problem and therefore his solution will scale
> miserably.
>
> Here is the OUTLINE of an extremely efficient solution
> in C. Because of the subtleties involved, I am not going
> to waste my time providing actual code.
>
> On Unix systems, a date is an integer (epoch). Therefore,
> first convert the textual date into an integer using the
> C mktime() function.
>
> Then the integer array is rapidly sorted to find the min/max.
mktime() is for PUSSIES like you, who are too dumb to manipulate
strings. And what's with this wimpy sidestep:
"Because of the subtleties involved, I am not going to waste my time
providing actual code."
No actual code? What the actual fuck? I thought you were a REAL MAN
who used C only? This is something you should be able to whip out in no
time.
And here's a newsflash, you blithering numbnut: there's no need to
create an integer array, read the dates, convert each date string into
an int, put the ints into the array, sort the array, get the min and
max, and convert the ints back to the original dd-mmm-yyyy format.
If you had a brain you'd realize you only need to read in each date
string, convert it to an int on the fly - without using mktime() - and
compare that to the previous int. Keep track of min and max during one
pass thru the list, and you're done.
Let me show you how, moron. In C.
First write a file with 10 million random date strings in the format
'dd-mmm-yyyy' (08-Mar-1987), which can't be sorted alphabetically
(lexicographically for a pretentious dweeb like you) to find the min and
max.
=========================================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]) {
int dates=atoi(argv[1]);
char *d[]={
"01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16","17","18","19","20",
"21","22","23","24","25","26","27","28"};
char *m[]={
"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
int y[1001];for(int i=0;i<=1001;i++){y[i]=i+1000;}
//set max range of day/mth/year randoms
int maxd=sizeof(d)/sizeof(d[0])-1;
int maxm=sizeof(m)/sizeof(m[0])-1;
int maxy=sizeof(y)/sizeof(y[0])-1;
//vars
int ry;
//char dtstr[11]
char rd[2],rm[3];
//seed
srand(time(NULL));
//write random date strings to file
//http://c-faq.com/lib/randrange.html
FILE *fp = fopen("datestrings.txt", "w");
for(int i=0;i<dates;i++){
strcpy(rd,d[rand()/(RAND_MAX/(maxd+1)+1)]);
strcpy(rm,m[rand()/(RAND_MAX/(maxm+1)+1)]);
ry=y[rand()/(RAND_MAX/(maxy+1)+1)];
//sprintf(dtstr,"%s-%s-%d",rd,rm,ry);
//fprintf(fp,"%s\n",dtstr);
fprintf(fp,"%s-%s-%d\n",rd,rm,ry);
}
fclose(fp);
printf("Finished writing date strings\n");
}
=========================================================================
$ time ./builddatestrings 10000000
Finished writing date strings
real 0m2.504s
user 0m2.307s
sys 0m0.130s
(~15x faster than python)
Now read the file, convert each date string to an int, and compare it to
the previous int.
=========================================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char
*mtht[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
char *mthn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
//convert 'dd-mmm-yyyy' to int yyyymmdd
int dtint (char *dtstr) {
char dts[9],y[4],mt[3],m[2],d[3],*ptr;
strncpy(y,dtstr+7,4);y[4]='\0';
strncpy(mt,dtstr+3,3);mt[3]='\0';
for(int j=0;j<12;j++){
if(strcmp(mt,mtht[j])==0){
strcpy(m,mthn[j]);m[2]='\0';break;}
}
strncpy(d,dtstr,2);d[2]='\0';
sprintf(dts,"%s%s%s",y,m,d);
return strtol(dts,&ptr,10);
}
int main(int argc, char *argv[]) {
char dtstr[12],mindts[11],maxdts[11];
int i=1,dti=0,mindti=0,maxdti=0;
int minline=1,maxline=1;
//read date strings, convert, compare
FILE *fp=fopen(argv[1],"r");
while(!feof(fp)){
fscanf (fp,"%s",&dtstr);
if(mindti>0){
dti=dtint(dtstr);
if(dti<mindti){mindti=dti;strcpy(mindts,dtstr);minline=i;}
if(dti>maxdti){maxdti=dti;strcpy(maxdts,dtstr);maxline=i;}
} else {
dti=mindti=maxdti=dtint(dtstr);
strcpy(mindts,dtstr);strcpy(maxdts,dtstr);
}
//printf ("Line %d: %s %d %s %s\n",i,dtstr,dti,mindts,maxdts);
i+=1;
}
fclose(fp);
printf("Min %s found at line %d\nMax %s found at line
%d\n",mindts,minline,maxdts,maxline);
}
=========================================================================
$ time ./getminmaxdatestrings datestrings.txt
Min 01-Jan-1000 found at line 60698
Max 28-Dec-2000 found at line 815752
real 0m3.491s
user 0m3.477s
sys 0m0.010s
See how short and sweet that is? Somebody with more C experience than
me could probably make it even faster.
And notice no reliance on array sorting or mktime(), which is for PUSSIES.
You're FIRED, idiot (actually, you're never hired).
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <mel@zzzzz.com> |
|---|---|
| Date | 2016-12-09 03:38 +0100 |
| Message-ID | <20161209033817.6653501a@maxa-pc> |
| In reply to | #383155 |
On Wed, 7 Dec 2016 12:27:40 -0500
DFS <nospam@dfs.com> wrote:
> Get the min and max from a list of dates formatted like this:
>
> 10-Mar-1998
> 20-Aug-1997
> 06-Sep-2009
> 23-Jan-2010
> 05-Nov-2010
> 03-Sep-2009
> 07-Nov-2014
> 08-Mar-2013
>
>
> My 5-line solution (python data structures only)
> ----------------------------------------------------------------
> dt=['10-Mar-1998','20-Aug-1997','06-Sep-2009','23-Jan-2010','05-Nov-2010','03-Sep-2009','07-Nov-2014','08-Mar-2013']
> m=[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07'),('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
> dt2=[]
> for d in dt:dt2.append((d[-4:]+dict(m)[d[3:6]]+d[:2],d))
> print min(dt2)[1]+'\n'+max(dt2)[1]
> ----------------------------------------------------------------
> $python getminmax.py
> 20-Aug-1997
> 07-Nov-2014
>
>
> <quote>
> My children, both were introduced to Linux when in grade 9-10.
> By the time they left high school they were capable of installing and
> configuring their own Linux systems. Now they are in university, one
> is in 4th year doing mathematics concentrating on discrete
> mathematics, hoping to do masters in AI. The other is in 3rd year CS.
>
> They can both code circles around you.
> </quote>
>
>
> Bring those little idiots on! If they can code circles around me,
> they can replicate that functionality in another language, in approx
> the same # of lines, using only builtin data structures.
Golang:
It would be lot less involving if you used one of standard date formats.
[bmaxa@maxa-pc hello]$ ./date_sort
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014
[bmaxa@maxa-pc hello]$ cat date_sort.go
package main
import (
"fmt"
"time"
"sort"
)
type MyTime []time.Time
func cvtMonth (s string) time.Month {
mmap := map[string]int{
"Jan":1,
"Feb":2,
"Mar":3,
"Apr":4,
"May":5,
"Jun":6,
"Jul":7,
"Aug":8,
"Sep":9,
"Oct":10,
"Nov":11,
}
return time.Month(mmap[s])
}
func main() {
dates := []string{"10-Mar-1998","20-Aug-1997","06-Sep-2009","23-Jan-2010",
"05-Nov-2010","03-Sep-2009","07-Nov-2014","08-Mar-2013"}
cnvrtd := make(MyTime,0)
for _,v := range dates {
var year,day int
var month string
fmt.Sscanf(v,"%2d-%3s-%4d",&day,&month,&year)
cnvrtd = append(cnvrtd,time.Date(year,cvtMonth(month),day,0,0,0,0,time.UTC))
}
sort.Sort(cnvrtd)
fmt.Println(cnvrtd)
}
func (this MyTime) Less(i,j int) bool {
return this[i].Before(this[j])
}
func (this MyTime) Len()int {
return len(this)
}
func (this MyTime) Swap(i,j int) {
this[i],this[j] = this[j],this[i]
}
func (this MyTime) String() (rc string) {
for i := range this {
rc+=fmt.Sprintf("%02d-%02d-%04d\n",this[i].Day(),this[i].Month(),this[i].Year())
}
return
}
--
press any key to continue or any other to quit
[toc] | [prev] | [next] | [standalone]
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Date | 2016-12-09 19:00 +0000 |
| Message-ID | <hgdos9893.g@rooftop.invalid> |
| In reply to | #383354 |
Melzzzzz <mel@zzzzz.com> wrote:
> On Wed, 7 Dec 2016 12:27:40 -0500
> DFS <nospam@dfs.com> wrote:
>
>> Get the min and max from a list of dates formatted like this:
>>
>> 10-Mar-1998
>> 20-Aug-1997
>> 06-Sep-2009
>> 23-Jan-2010
>> 05-Nov-2010
>> 03-Sep-2009
>> 07-Nov-2014
>> 08-Mar-2013
>>
>>
...
>>
>>
>> Bring those little idiots on! If they can code circles around me,
>> they can replicate that functionality in another language, in approx
>> the same # of lines, using only builtin data structures.
> Golang:
> It would be lot less involving if you used one of standard date formats.
>
> [bmaxa@maxa-pc hello]$ ./date_sort
> 20-08-1997
> 10-03-1998
> 03-09-2009
> 06-09-2009
> 23-01-2010
> 05-11-2010
> 08-03-2013
> 07-11-2014
>
> [bmaxa@maxa-pc hello]$ cat date_sort.go
> package main
>
> import (
> "fmt"
...
>
>
Times for bash, python, go, and C:
anon@lowtide:~/code/dfsdates$ time . blah
20-Aug-1997
07-Nov-2014
real 0m0.042s
user 0m0.000s
sys 0m0.008s
anon@lowtide:~/code/dfsdates$ time python getminmax.py
20-Aug-1997
07-Nov-2014
real 0m0.031s
user 0m0.020s
sys 0m0.008s
anon@lowtide:~/code/dfsdates$ time ./date_sort
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014
real 0m0.003s
user 0m0.000s
sys 0m0.000s
anon@lowtide:~/code/dfsdates$ time ./flah
20-Aug-1997
07-Nov-2014
real 0m0.001s
user 0m0.000s
sys 0m0.004s
anon@lowtide:~/code/dfsdates$
flah.c:
---------------------------------------
#include <stdio.h>
#define __USE_XOPEN
#include <time.h>
#include <string.h>
#include <stdlib.h>
struct mdy {
int d;
int m;
int y;
};
long getints(struct mdy *, char *);
int compar(const void *,const void *);
int main(int argc, char *argv[])
{
char * dates[] = {
"10-Mar-1998",
"20-Aug-1997",
"06-Sep-2009",
"23-Jan-2010",
"05-Nov-2010",
"03-Sep-2009",
"07-Nov-2014",
"08-Mar-2013"
};
int datecount=sizeof(dates)/sizeof(dates[0]);
time_t seconds=0;
struct tm mytm={0};
struct mdy mymdy={0};
long mylongs[datecount];
long i=0;
char buf[100]={0};
for(i=0;i<datecount;i++)
{
getints(&mymdy,dates[i]);
mytm.tm_mday=mymdy.d;
mytm.tm_mon=mymdy.m;
mytm.tm_year=mymdy.y-1900;
seconds=mktime(&mytm);
mylongs[i]=(long)seconds;
}
qsort(mylongs,datecount,sizeof(long),compar);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[0]));
printf("%s\n",buf);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[datecount-1]));
printf("%s\n",buf);
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)
{
return ( *(long *)a -*(long *)b );
}
---------------------------------------
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <mel@zzzzz.com> |
|---|---|
| Date | 2016-12-10 00:33 +0100 |
| Message-ID | <20161210003352.7436a0f1@maxa-pc> |
| In reply to | #383464 |
On Fri, 9 Dec 2016 19:00:26 +0000 (UTC)
deplorable owl <owl@rooftop.invalid> wrote:
> Melzzzzz <mel@zzzzz.com> wrote:
> > On Wed, 7 Dec 2016 12:27:40 -0500
> > DFS <nospam@dfs.com> wrote:
> >
> >> Get the min and max from a list of dates formatted like this:
> >>
> >> 10-Mar-1998
> >> 20-Aug-1997
> >> 06-Sep-2009
> >> 23-Jan-2010
> >> 05-Nov-2010
> >> 03-Sep-2009
> >> 07-Nov-2014
> >> 08-Mar-2013
> >>
> >>
> ...
> >>
> >>
> >> Bring those little idiots on! If they can code circles around me,
> >> they can replicate that functionality in another language, in
> >> approx the same # of lines, using only builtin data structures.
> > Golang:
> > It would be lot less involving if you used one of standard date
> > formats.
> >
> > [bmaxa@maxa-pc hello]$ ./date_sort
> > 20-08-1997
> > 10-03-1998
> > 03-09-2009
> > 06-09-2009
> > 23-01-2010
> > 05-11-2010
> > 08-03-2013
> > 07-11-2014
> >
> > [bmaxa@maxa-pc hello]$ cat date_sort.go
> > package main
> >
> > import (
> > "fmt"
> ...
> >
> >
>
> Times for bash, python, go, and C:
>
> anon@lowtide:~/code/dfsdates$ time . blah
> 20-Aug-1997
> 07-Nov-2014
>
> real 0m0.042s
> user 0m0.000s
> sys 0m0.008s
> anon@lowtide:~/code/dfsdates$ time python getminmax.py
> 20-Aug-1997
> 07-Nov-2014
>
> real 0m0.031s
> user 0m0.020s
> sys 0m0.008s
> anon@lowtide:~/code/dfsdates$ time ./date_sort
> 20-08-1997
> 10-03-1998
> 03-09-2009
> 06-09-2009
> 23-01-2010
> 05-11-2010
> 08-03-2013
> 07-11-2014
>
>
> real 0m0.003s
> user 0m0.000s
> sys 0m0.000s
> anon@lowtide:~/code/dfsdates$ time ./flah
> 20-Aug-1997
> 07-Nov-2014
>
> real 0m0.001s
> user 0m0.000s
> sys 0m0.004s
> anon@lowtide:~/code/dfsdates$
>
> flah.c:
> ---------------------------------------
> #include <stdio.h>
> #define __USE_XOPEN
> #include <time.h>
> #include <string.h>
> #include <stdlib.h>
>
> struct mdy {
> int d;
> int m;
> int y;
> };
>
> long getints(struct mdy *, char *);
> int compar(const void *,const void *);
>
> int main(int argc, char *argv[])
> {
> char * dates[] = {
> "10-Mar-1998",
> "20-Aug-1997",
> "06-Sep-2009",
> "23-Jan-2010",
> "05-Nov-2010",
> "03-Sep-2009",
> "07-Nov-2014",
> "08-Mar-2013"
> };
>
> int datecount=sizeof(dates)/sizeof(dates[0]);
> time_t seconds=0;
> struct tm mytm={0};
> struct mdy mymdy={0};
> long mylongs[datecount];
> long i=0;
> char buf[100]={0};
>
> for(i=0;i<datecount;i++)
> {
> getints(&mymdy,dates[i]);
>
> mytm.tm_mday=mymdy.d;
> mytm.tm_mon=mymdy.m;
> mytm.tm_year=mymdy.y-1900;
>
> seconds=mktime(&mytm);
> mylongs[i]=(long)seconds;
> }
>
> qsort(mylongs,datecount,sizeof(long),compar);
>
> strftime(buf,sizeof buf,"%d-%b-%Y",
> localtime((time_t *)&mylongs[0]));
> printf("%s\n",buf);
> strftime(buf,sizeof buf,"%d-%b-%Y",
> localtime((time_t *)&mylongs[datecount-1]));
> printf("%s\n",buf);
>
> 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)
> {
> return ( *(long *)a -*(long *)b );
> }
> ---------------------------------------
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
import (
"fmt"
"math/rand"
"time"
"sort"
)
type MyTime []time.Time
func cvtToMonth (s string) time.Month {
mmap := map[string]int{
"Jan":1,
"Feb":2,
"Mar":3,
"Apr":4,
"May":5,
"Jun":6,
"Jul":7,
"Aug":8,
"Sep":9,
"Oct":10,
"Nov":11,
"Dec":12,
}
return time.Month(mmap[s])
}
func cvtFromMonth(in time.Month) string {
months := []string{"","Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"}
return months[int(in)]
}
func main() {
rand.Seed(time.Now().Unix())
dates := GenDates(30,2015,100000)
cnvrtd := make(MyTime,0)
for k,_ := range dates {
var year,day int
var month string
fmt.Sscanf(k,"%2d-%3s-%4d",&day,&month,&year)
cnvrtd = append(cnvrtd,time.Date(year,cvtToMonth(month),day,0,0,0,0,time.UTC))
}
fmt.Printf("%d unique dates\n\n",len(dates))
sort.Sort(cnvrtd)
first10 := cnvrtd[:10]
last10 := cnvrtd[len(cnvrtd)-10:]
fmt.Println(first10)
fmt.Println(last10)
}
func (this MyTime) Less(i,j int) bool {
return this[i].Before(this[j])
}
func (this MyTime) Len()int {
return len(this)
}
func (this MyTime) Swap(i,j int) {
this[i],this[j] = this[j],this[i]
}
func (this MyTime) String() (rc string) {
for i := range this {
rc+=fmt.Sprintf("%02d-%3s-%04d\n",this[i].Day(),
cvtFromMonth(this[i].Month()),this[i].Year())
}
return
}
func random(min, max int) int {
return rand.Intn(max - min + 1) + min
}
func GenDates(minyear,maxyear,count int) map[string]int {
rc := make(map[string]int,0)
for i := 0;i<count;i++ {
r := time.Date(random(minyear,maxyear),time.Month(random(1,12)),random(1,31),
0,0,0,0,time.UTC)
rc [fmt.Sprintf("%2d-%3s-%4d",r.Day(),
cvtFromMonth(r.Month()),r.Year())]++
}
return rc
}
--
press any key to continue or any other to quit
[toc] | [prev] | [next] | [standalone]
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Date | 2016-12-10 05:24 +0000 |
| Message-ID | <hgjdu9x83.g4a@rooftop.invalid> |
| In reply to | #383503 |
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;
}
---------------------------------------------------------------
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <Melzzzzz@zzzzz.com> |
|---|---|
| Date | 2016-12-10 06:54 +0100 |
| Message-ID | <o2g5a7$n62$1@news.albasani.net> |
| In reply to | #383512 |
On 10/12/16 06:24 AM, deplorable owl wrote: > 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). > Nah, you have to create strings in DFS's format, then parse those strings ;p It's not same program ;) I wouldn't do it in C as I have to implement hash table first ;) Or just create 100k random dates in one list then parse, with dupes. -- press any key to continue or any other to quit...
[toc] | [prev] | [next] | [standalone]
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Date | 2016-12-10 06:25 +0000 |
| Message-ID | <adhgb03.alle@rooftop.invalid> |
| In reply to | #383514 |
Melzzzzz <Melzzzzz@zzzzz.com> wrote: > On 10/12/16 06:24 AM, deplorable owl wrote: >> 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). >> > Nah, you have to create strings in DFS's format, then parse those > strings ;p It's not same program ;) I create teh strings in DFS format. I just do it last. :) > I wouldn't do it in C as I have to implement hash table first ;) > Or just create 100k random dates in one list then parse, with dupes. I noticed I left a whole function in there from the other code that isn't even used. BTW, what's the proper approach to randomizing such a huge number of values? (A large enough pool of seconds so that randoms would have a good chance of falling on 100,000 different days).
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <Melzzzzz@zzzzz.com> |
|---|---|
| Date | 2016-12-10 07:28 +0100 |
| Message-ID | <o2g7a6$7sj$1@news.albasani.net> |
| In reply to | #383515 |
On 10/12/16 07:25 AM, deplorable owl wrote: > Melzzzzz <Melzzzzz@zzzzz.com> wrote: > > BTW, what's the proper approach to randomizing such a huge number of > values? (A large enough pool of seconds so that randoms would have > a good chance of falling on 100,000 different days). > > You don't have to just filter out dupes ;p It is not needed to have 100000k uniques at all. -- press any key to continue or any other to quit...
[toc] | [prev] | [next] | [standalone]
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Date | 2016-12-10 19:56 +0000 |
| Message-ID | <ahjgcks002.gqe@rooftop.invalid> |
| In reply to | #383516 |
Melzzzzz <Melzzzzz@zzzzz.com> wrote: > On 10/12/16 07:25 AM, deplorable owl wrote: >> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >> >> BTW, what's the proper approach to randomizing such a huge number of >> values? (A large enough pool of seconds so that randoms would have >> a good chance of falling on 100,000 different days). >> >> > You don't have to just filter out dupes ;p > It is not needed to have 100000k uniques at all. Yeah, but filtering is just to get uniques. Say you want 100000 unique days using random second values, minimizing dups and generating exactly 100000 values, how would you approach that? rand() and random() both work over range 0-RAND_MAX, which on my system is a range of 2.14 billion. There are 8.64 billion seconds in 100,000 days. Maybe stitch larger numbers from smaller random pieces? I used a random multiplier of 0-9 over +/-(1 billion), hoping to get range from +/-(9 billion) but that's not working great.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-12-10 15:19 -0500 |
| Message-ID | <o2hntl$n47$1@dont-email.me> |
| In reply to | #383584 |
On 12/10/2016 02:56 PM, deplorable owl wrote:
> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>
>>> BTW, what's the proper approach to randomizing such a huge number of
>>> values? (A large enough pool of seconds so that randoms would have
>>> a good chance of falling on 100,000 different days).
>>>
>>>
>> You don't have to just filter out dupes ;p
>> It is not needed to have 100000k uniques at all.
>
> Yeah, but filtering is just to get uniques. Say you want 100000 unique
> days using random second values, minimizing dups and generating exactly
> 100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 10 or 100 or 1000 more randoms at a time and test the row
count after every set.
4. When you get to 100K rows, read them back into an array (and shuffle
it if you need it in random order)?
> rand() and random() both work
> over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
> There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
> numbers from smaller random pieces? I used a random multiplier of 0-9
> over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
> not working great.
>
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-12-10 15:23 -0500 |
| Message-ID | <o2ho5i$n47$3@dont-email.me> |
| In reply to | #383584 |
On 12/10/2016 02:56 PM, deplorable owl wrote:
> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>
>>> BTW, what's the proper approach to randomizing such a huge number of
>>> values? (A large enough pool of seconds so that randoms would have
>>> a good chance of falling on 100,000 different days).
>>>
>>>
>> You don't have to just filter out dupes ;p
>> It is not needed to have 100000k uniques at all.
>
> Yeah, but filtering is just to get uniques. Say you want 100000 unique
> days using random second values, minimizing dups and generating exactly
> 100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.
4. Read them back into an array (and shuffle it if you need it in
random order)?
> rand() and random() both work
> over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
> There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
> numbers from smaller random pieces? I used a random multiplier of 0-9
> over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
> not working great.
>
[toc] | [prev] | [next] | [standalone]
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Date | 2016-12-10 20:44 +0000 |
| Message-ID | <ahjgob040.ae@rooftop.invalid> |
| In reply to | #383592 |
DFS <nospam@dfs.com> wrote: > On 12/10/2016 02:56 PM, deplorable owl wrote: >> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>> On 10/12/16 07:25 AM, deplorable owl wrote: >>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>> >>>> BTW, what's the proper approach to randomizing such a huge number of >>>> values? (A large enough pool of seconds so that randoms would have >>>> a good chance of falling on 100,000 different days). >>>> >>>> >>> You don't have to just filter out dupes ;p >>> It is not needed to have 100000k uniques at all. >> >> Yeah, but filtering is just to get uniques. Say you want 100000 unique >> days using random second values, minimizing dups and generating exactly >> 100000 values, how would you approach that? > > > 1. Write 100K random dates to a table with a PK > > 2. Count the rows - it would very likely be less than 100K > > 3. Write 1 more random at a time and test the row count after every > INSERT, until you hit exactly 100K. > > 4. Read them back into an array (and shuffle it if you need it in > random order)? > It's not really about dates -- that's just the application here -- but about the number range. The problem is generating the random seconds. 100,000 days is 8.64 billion seconds. How to get a random generation, minimizing dups, while generating exactly 100,000 values (not after stripping dups, but for exactly 100,000 iterations), over such a huge range when rand() and random() work over a range of 0-RAND_MAX, which is a range of 0-2.14 billion. > > >> rand() and random() both work >> over range 0-RAND_MAX, which on my system is a range of 2.14 billion. >> There are 8.64 billion seconds in 100,000 days. Maybe stitch larger >> numbers from smaller random pieces? I used a random multiplier of 0-9 >> over +/-(1 billion), hoping to get range from +/-(9 billion) but that's >> not working great. >> >
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-12-10 17:55 -0500 |
| Message-ID | <o2i132$ll7$1@dont-email.me> |
| In reply to | #383597 |
On 12/10/2016 03:44 PM, deplorable owl wrote: > DFS <nospam@dfs.com> wrote: >> On 12/10/2016 02:56 PM, deplorable owl wrote: >>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>> On 10/12/16 07:25 AM, deplorable owl wrote: >>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>>> >>>>> BTW, what's the proper approach to randomizing such a huge number of >>>>> values? (A large enough pool of seconds so that randoms would have >>>>> a good chance of falling on 100,000 different days). >>>>> >>>>> >>>> You don't have to just filter out dupes ;p >>>> It is not needed to have 100000k uniques at all. >>> >>> Yeah, but filtering is just to get uniques. Say you want 100000 unique >>> days using random second values, minimizing dups and generating exactly >>> 100000 values, how would you approach that? >> >> >> 1. Write 100K random dates to a table with a PK >> >> 2. Count the rows - it would very likely be less than 100K >> >> 3. Write 1 more random at a time and test the row count after every >> INSERT, until you hit exactly 100K. >> >> 4. Read them back into an array (and shuffle it if you need it in >> random order)? >> > > It's not really about dates -- that's just the application here -- but > about the number range. The problem is generating the random seconds. > 100,000 days is 8.64 billion seconds. How to get a random generation, > minimizing dups, while generating exactly 100,000 values (not after > stripping dups, but for exactly 100,000 iterations), over such a huge > range when rand() and random() work over a range of 0-RAND_MAX, which > is a range of 0-2.14 billion. You don't need to generate 8,640,000,000 randoms at once. Gen 100K randoms for the days and 100K randoms for the seconds, then concatenate them. rand1: 20090615 rand2: 134530 becomes 2009-06-15 13:45:30 >>> rand() and random() both work >>> over range 0-RAND_MAX, which on my system is a range of 2.14 billion. >>> There are 8.64 billion seconds in 100,000 days. Maybe stitch larger >>> numbers from smaller random pieces? I used a random multiplier of 0-9 >>> over +/-(1 billion), hoping to get range from +/-(9 billion) but that's >>> not working great. >>> >>
[toc] | [prev] | [next] | [standalone]
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Date | 2016-12-11 00:02 +0000 |
| Message-ID | <aybudaoc993.ag@rooftop.invalid> |
| In reply to | #383615 |
DFS <nospam@dfs.com> wrote: > On 12/10/2016 03:44 PM, deplorable owl wrote: >> DFS <nospam@dfs.com> wrote: >>> On 12/10/2016 02:56 PM, deplorable owl wrote: >>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>>> On 10/12/16 07:25 AM, deplorable owl wrote: >>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>>>> >>>>>> BTW, what's the proper approach to randomizing such a huge number of >>>>>> values? (A large enough pool of seconds so that randoms would have >>>>>> a good chance of falling on 100,000 different days). >>>>>> >>>>>> >>>>> You don't have to just filter out dupes ;p >>>>> It is not needed to have 100000k uniques at all. >>>> >>>> Yeah, but filtering is just to get uniques. Say you want 100000 unique >>>> days using random second values, minimizing dups and generating exactly >>>> 100000 values, how would you approach that? >>> >>> >>> 1. Write 100K random dates to a table with a PK >>> >>> 2. Count the rows - it would very likely be less than 100K >>> >>> 3. Write 1 more random at a time and test the row count after every >>> INSERT, until you hit exactly 100K. >>> >>> 4. Read them back into an array (and shuffle it if you need it in >>> random order)? >>> >> >> It's not really about dates -- that's just the application here -- but >> about the number range. The problem is generating the random seconds. >> 100,000 days is 8.64 billion seconds. How to get a random generation, >> minimizing dups, while generating exactly 100,000 values (not after >> stripping dups, but for exactly 100,000 iterations), over such a huge >> range when rand() and random() work over a range of 0-RAND_MAX, which >> is a range of 0-2.14 billion. > > > You don't need to generate 8,640,000,000 randoms at once. > > Gen 100K randoms for the days and 100K randoms for the seconds, then > concatenate them. > > rand1: 20090615 > rand2: 134530 > > becomes 2009-06-15 13:45:30 > Which is still a day value of 20090615. 86400 different seconds values will fall on that day, hence the huge number of seconds values required for 100000 unique days. anon@lowtide:~/code/dfsdates$ date -d "2009-06-15 13:45:30" +%s 1245087930 anon@lowtide:~/code/dfsdates$ date -d "2009-06-15 4:10:12" +%s 1245053412 anon@lowtide:~/code/dfsdates$ date -d @1245087930 +%d-%b-%Y 15-Jun-2009 anon@lowtide:~/code/dfsdates$ date -d @1245053412 +%d-%b-%Y 15-Jun-2009 anon@lowtide:~/code/dfsdates$ You can easily cheat and generate all seconds values sequentially over a 273 year period, then enter them modulo 86400 into an array of 100000, but that's an *ordered* array, and what you want is randoms. (Randomizing the 100000 is not a problem, but that avoids the challenge). Generating the random seconds that give 100000 unique *day* values (well, fewest dups) for those seconds is the difficulty. Again, I don't care about this as a "date" problem. I want to know the best approach for randomizing over a huge range (far exceeding RAND_MAX) with minimal dups.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-12-10 19:39 -0500 |
| Message-ID | <o2i755$3d9$1@dont-email.me> |
| In reply to | #383618 |
On 12/10/2016 07:02 PM, deplorable owl wrote: > DFS <nospam@dfs.com> wrote: >> On 12/10/2016 03:44 PM, deplorable owl wrote: >>> DFS <nospam@dfs.com> wrote: >>>> On 12/10/2016 02:56 PM, deplorable owl wrote: >>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>>>> On 10/12/16 07:25 AM, deplorable owl wrote: >>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote: >>>>>>> >>>>>>> BTW, what's the proper approach to randomizing such a huge number of >>>>>>> values? (A large enough pool of seconds so that randoms would have >>>>>>> a good chance of falling on 100,000 different days). >>>>>>> >>>>>>> >>>>>> You don't have to just filter out dupes ;p >>>>>> It is not needed to have 100000k uniques at all. >>>>> >>>>> Yeah, but filtering is just to get uniques. Say you want 100000 unique >>>>> days using random second values, minimizing dups and generating exactly >>>>> 100000 values, how would you approach that? >>>> >>>> >>>> 1. Write 100K random dates to a table with a PK >>>> >>>> 2. Count the rows - it would very likely be less than 100K >>>> >>>> 3. Write 1 more random at a time and test the row count after every >>>> INSERT, until you hit exactly 100K. >>>> >>>> 4. Read them back into an array (and shuffle it if you need it in >>>> random order)? >>>> >>> >>> It's not really about dates -- that's just the application here -- but >>> about the number range. The problem is generating the random seconds. >>> 100,000 days is 8.64 billion seconds. How to get a random generation, >>> minimizing dups, while generating exactly 100,000 values (not after >>> stripping dups, but for exactly 100,000 iterations), over such a huge >>> range when rand() and random() work over a range of 0-RAND_MAX, which >>> is a range of 0-2.14 billion. >> >> >> You don't need to generate 8,640,000,000 randoms at once. >> >> Gen 100K randoms for the days and 100K randoms for the seconds, then >> concatenate them. >> >> rand1: 20090615 >> rand2: 134530 >> >> becomes 2009-06-15 13:45:30 >> > > Which is still a day value of 20090615. > 86400 different seconds values will fall on that day, hence the > huge number of seconds values required for 100000 unique days. If you're concerned about randomness and uniqueness, you don't need to generate 86,400 random numbers per day. All you need is 100K numbers for the days, and 100K numbers for the seconds. For all 100K days. Each random number from the 100K pool is just as random as one chosen from a pool of 86,400 generated each day. You're not necessarily going to get more unique numbers just by doing a random generation every day. http://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/ > anon@lowtide:~/code/dfsdates$ date -d "2009-06-15 13:45:30" +%s > 1245087930 > anon@lowtide:~/code/dfsdates$ date -d "2009-06-15 4:10:12" +%s > 1245053412 > anon@lowtide:~/code/dfsdates$ date -d @1245087930 +%d-%b-%Y > 15-Jun-2009 > anon@lowtide:~/code/dfsdates$ date -d @1245053412 +%d-%b-%Y > 15-Jun-2009 > anon@lowtide:~/code/dfsdates$ > > You can easily cheat and generate all seconds values sequentially over a > 273 year period, then enter them modulo 86400 into an array of 100000, but > that's an *ordered* array, and what you want is randoms. (Randomizing the > 100000 is not a problem, but that avoids the challenge). Generating the > random seconds that give 100000 unique *day* values (well, fewest dups) > for those seconds is the difficulty. Again, I don't care about this as > a "date" problem. I want to know the best approach for randomizing > over a huge range (far exceeding RAND_MAX) with minimal dups. So you're not actually concerned about getting 100K random dates and times? Sounds like you're into a math problem: maybe post on sci.math
[toc] | [prev] | [next] | [standalone]
Page 4 of 6 — ← Prev page 1 2 3 [4] 5 6 Next page →
Back to top | Article view | comp.os.linux.advocacy
csiph-web