Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #377239
| From | deplorable owl <owl@rooftop.invalid> |
|---|---|
| Newsgroups | comp.os.linux.advocacy |
| Subject | Re: Ping sbd: another programming challenge for your developmentally challenged children |
| Date | 2016-10-22 01:06 +0000 |
| Organization | O.W.L. |
| Message-ID | <hjagd803r.tji@rooftop.invalid> (permalink) |
| References | <nt5rdf$35m$2@dont-email.me> <nt6ah6024gd@news3.newsguy.com> <nuanc6$909$2@dont-email.me> <ahjgud092.agx3@rooftop.invalid> <nud9kv$434$1@dont-email.me> |
DFS <nospam@dfs.com> wrote:
> On 10/21/2016 4:53 AM, deplorable owl wrote:
>
>> python pwned by C.
>
> I don't see any C.
>
The code is at the bottom.
I made some changes so that it will now handle varying leading
quote marks and take its data from a file. Also got rid of some
function calls, so it's faster.
anon@lowtide:~/code/blah$ cat data
> Intel doesn't have to write a kernel from scratch. Nor does
Android. They can use Linux. And if they need to make modifications for
their own benefit, that's fine, just share that back. They benefited by
not having to develop from scratch. But they need to give something back
in return. Like the work they added. Both parties are give and take
something from each other. I'll take that over the BSD license any day
of the week.
anon@lowtide:~/code/blah$
anon@lowtide:~/code/blah$ cat data2
>> >> > Intel doesn't have to write a kernel from scratch. Nor does
Android. They can use Linux. And if they need to make modifications for
their own benefit, that's fine, just share that back. They benefited by
not having to develop from scratch. But they need to give something back
in return. Like the work they added. Both parties are give and take
something from each other. I'll take that over the BSD license any day
of the week.
anon@lowtide:~/code/blah$
anon@lowtide:~/code/blah$ ./nah data 15 40 1
15 > Intel doesn't have to write a kernel
16 > from scratch. Nor does Android. They
17 > can use Linux. And if they need to
18 > make modifications for their own
19 > benefit, that's fine, just share that
20 > back. They benefited by not having to
21 > develop from scratch. But they need to
22 > give something back in return. Like
23 > the work they added. Both parties are
24 > give and take something from each
25 > other. I'll take that over the BSD
26 > license any day of the week.
anon@lowtide:~/code/blah$ ./nah data2 15 40 1
15 >> >> > Intel doesn't have to write a
16 >> >> > kernel from scratch. Nor does
17 >> >> > Android. They can use Linux.
18 >> >> > And if they need to make
19 >> >> > modifications for their own
20 >> >> > benefit, that's fine, just share
21 >> >> > that back. They benefited by not
22 >> >> > having to develop from scratch.
23 >> >> > But they need to give something
24 >> >> > back in return. Like the work
25 >> >> > they added. Both parties are
26 >> >> > give and take something from
27 >> >> > each other. I'll take that over
28 >> >> > the BSD license any day of the
29 >> >> > week.
anon@lowtide:~/code/blah$
Running Melzzzzz's haskell code on my system, the speeds are about the
same, with the C being slightly faster about 80 percent of the time,
but it's very close.
anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt
real 0m0.010s
user 0m0.008s
sys 0m0.000s
anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
real 0m0.007s
user 0m0.004s
sys 0m0.000s
anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt
real 0m0.008s
user 0m0.004s
sys 0m0.000s
anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
real 0m0.007s
user 0m0.004s
sys 0m0.000s
anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt
real 0m0.008s
user 0m0.004s
sys 0m0.000s
anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
real 0m0.006s
user 0m0.004s
sys 0m0.000s
anon@lowtide:~/code/blah$
-------------------------- begin code --------------------------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
void split(char *,char *,int, int, char *, int);
int main(int argc, char *argv[])
{
int i=0;
int c=0;
long filesize=0;
char *txt;
char *str;
char *txtsave;
char *quotes;
int quotecount=0;
char *s;
char *save;
if(argc!=5)
{
fprintf(stderr,"argc!=4\n");
exit(1);
}
FILE *fp=fopen(argv[1],"r");
if(fp==NULL)
{
fprintf(stderr,"fopen\n");
exit(1);
}
fseek(fp,0,SEEK_END);
filesize=ftell(fp);
fseek(fp,0,SEEK_SET);
txt=malloc(filesize+1);
if(txt==NULL)
{
fprintf(stderr,"txt malloc\n");
exit(1);
}
str=malloc(filesize+1);
if(str==NULL)
{
fprintf(stderr,"str malloc\n");
exit(1);
}
txtsave=txt;
while((c=fgetc(fp))!=EOF)
{
if(c=='\n')
{
*txt++=' ';
}
else
{
*txt++=c;
}
}
txt=txtsave;
s=txt;
save=s;
while(*s=='>'||*s==' ')
{
s++;
quotecount++;
}
quotes=malloc(quotecount+1);
if(quotes==NULL)
{
fprintf(stderr,"quotes malloc\n");
exit(1);
}
char *quotessave=quotes;
s=save;
while(*s=='>'||*s==' ')
{
*quotes++=*s++;
}
s=save;
quotes=quotessave;
for(i=0;i<atoi(argv[4]);i++)
{
split(str,txt,atoi(argv[2]),atoi(argv[3]),quotes,quotecount);
}
free(quotes);
free(txt);
fclose(fp);
return 0;
}
void split(char *str,char *t,int n,int m, char *quotes, int quotecount)
{
char *s=t;
char *ssave=str;
int i=0;
int sc=0;
while(*s=='>'||*s==' ')
{
s++;
}
while(*t=='>'||*t==' ')
{
t++;
}
while(*t++!='\0')
{
if(*t==' ')
{
sc++;
}
if(i++==m-quotecount)
{
if(sc>0)
{
while(*t!=' ')
{
t--;
}
}
while(t<s)
{
t++;
}
while(s<=t&&*s!='\0')
{
*str++=*s++;
}
*str='\0';
str=ssave;
printf("%d %s%s\n",n++,quotes,str);
i=0;
}
}
printf("%d %s%s\n\n",n++,quotes,s);
}
-------------------------- end code --------------------------------
Back to comp.os.linux.advocacy | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 11:42 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Adlbifhr Mjduhgfks <am@random.us> - 2016-10-06 20:00 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 19:31 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 00:20 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 20:55 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 01:04 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 22:11 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 02:19 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 23:20 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 03:33 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 00:02 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 04:22 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children fr314159@gmail.com - 2016-10-07 08:08 -0700
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-07 10:42 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-08 03:13 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-08 03:19 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-08 05:37 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:09 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-10 14:11 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:37 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-10 16:56 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 10:26 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-08 10:48 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <fretwizzer@gmail.com> - 2016-10-08 07:58 -0700
Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 15:04 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-09 10:24 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-08 15:28 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-08 15:41 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-08 19:57 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 17:23 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 10:24 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-08 10:44 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-08 17:11 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-08 13:46 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-08 20:01 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children ronb <ronb02NOSPAM@gmail.com> - 2016-10-08 23:23 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-08 20:43 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 01:15 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 01:13 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children ronb <ronb02NOSPAM@gmail.com> - 2016-10-09 02:08 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 02:13 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-09 08:15 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:27 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children ronb <ronb02NOSPAM@gmail.com> - 2016-10-08 23:22 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-08 22:54 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 15:13 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-09 18:14 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 16:19 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-09 18:25 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:21 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 10:50 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children Snit <usenet@gallopinginsanity.com> - 2016-11-01 10:09 -0700
Re: Ping sbd: another programming challenge for your developmentally challenged children William Poaster <wp@dev.null> - 2016-10-09 22:29 +0100
Re: Ping sbd: another programming challenge for your developmentally challenged children Marek Novotny <marek.novotny@marspolar.com> - 2016-10-09 13:38 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 23:58 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:29 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children William Poaster <wp@dev.null> - 2016-10-10 13:41 +0100
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 12:25 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-10 13:33 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 10:51 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 12:45 -0500
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 16:35 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-10 18:54 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 21:56 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-10 22:48 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-11 00:02 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 21:58 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 21:58 -0600
Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-07 17:56 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 13:25 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Adlbifhr Mjduhgfks <am@random.us> - 2016-10-08 00:12 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-08 10:40 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-10 13:34 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 04:15 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 16:37 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-07 20:34 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <frelwizzen@gmail.com> - 2016-10-07 11:10 -0700
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-20 11:20 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-21 08:53 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-21 13:19 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-21 10:45 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 01:06 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <Melzzzzz@zzzzz.com> - 2016-10-22 02:15 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 02:40 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-22 05:00 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 16:34 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-22 23:14 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-22 18:24 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-25 23:20 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-26 05:22 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-26 11:26 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-26 20:42 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-27 01:45 +0200
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-27 01:21 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-22 09:33 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 16:50 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-06 21:25 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 16:30 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <fretwizzer@gmail.com> - 2016-10-07 09:44 -0700
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 17:20 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 15:24 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 20:01 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 16:50 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 21:37 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 17:54 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 22:11 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 13:51 -0400
Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 18:13 +0000
Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <frelwizzen@gmail.com> - 2016-10-07 11:10 -0700
csiph-web