Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #425480 > unrolled thread
| Started by | fr314159@gmail.com |
|---|---|
| First post | 2017-08-02 11:14 -0700 |
| Last post | 2017-08-06 22:37 -0700 |
| Articles | 20 on this page of 83 — 14 participants |
Back to article view | Back to comp.os.linux.advocacy
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: FizzBuzz: an Interview Question ( for programmers ). fr314159@gmail.com - 2017-08-02 11:14 -0700
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-02 20:19 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-02 21:06 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-02 21:37 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-03 01:46 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-03 04:32 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-03 05:01 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-03 05:06 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-03 05:15 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-04 05:02 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-04 13:52 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-04 14:00 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Marek Novotny <marek.novotny@marspolar.com> - 2017-08-04 12:56 -0500
Re: FizzBuzz: an Interview Question ( for programmers ). Steve Carroll <fretwizzer@gmail.com> - 2017-08-04 11:03 -0700
Re: FizzBuzz: an Interview Question ( for programmers ). Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-04 18:05 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Steve Carroll <fretwizzer@gmail.com> - 2017-08-04 11:08 -0700
Re: FizzBuzz: an Interview Question ( for programmers ). Snit <usenet@gallopinginsanity.com> - 2017-08-04 11:23 -0700
Re: Marek Novotny is a command line jockey. Marek Novotny <marek.novotny@marspolar.com> - 2017-08-04 14:24 -0500
Re: Marek Novotny is a command line jockey. Snit <usenet@gallopinginsanity.com> - 2017-08-04 12:45 -0700
Re: This is better, no ? Marek Novotny <marek.novotny@marspolar.com> - 2017-08-04 15:24 -0500
Re: Marek Novotny is a command line jockey. Snit <usenet@gallopinginsanity.com> - 2017-08-04 12:38 -0700
Re: My code is twice as fast as Owl's. owl <owl@rooftop.invalid> - 2017-08-03 03:12 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). "F. Russell" <fr@random.info> - 2017-08-02 23:04 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). "F. Russell" <fr@random.info> - 2017-08-02 23:25 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). owl <owl@rooftop.invalid> - 2017-08-03 01:50 +0000
Re: Fabian's code is always slower. owl <owl@rooftop.invalid> - 2017-08-03 04:41 +0000
Re: Fabian's code is always slower. owl <owl@rooftop.invalid> - 2017-08-03 05:17 +0000
Re: What's easier to read/maintain ? owl <owl@rooftop.invalid> - 2017-08-03 05:57 +0000
Re: Fabian's code is always slower. fr314159@gmail.com - 2017-08-03 08:21 -0700
Re: Fabian's code is always slower. Steve Carroll <fretwizzer@gmail.com> - 2017-08-03 09:24 -0700
Re: Fabian's code is always slower. owl <owl@rooftop.invalid> - 2017-08-03 18:41 +0000
Re: FizzBuzz: an Interview Question ( for programmers ). Snit <usenet@gallopinginsanity.com> - 2017-08-03 13:49 -0700
Re: 4 lines, 4 states. Snit <usenet@gallopinginsanity.com> - 2017-08-03 22:11 -0700
Re: 4 lines, 4 states. Snit <usenet@gallopinginsanity.com> - 2017-08-03 22:47 -0700
Re: 4 lines, 4 states. Snit <usenet@gallopinginsanity.com> - 2017-08-03 22:52 -0700
Re: Mozilla ThunderBird. Steve Carroll <fretwizzer@gmail.com> - 2017-08-04 08:54 -0700
Re: Mozilla ThunderBird. Snit <usenet@gallopinginsanity.com> - 2017-08-04 10:43 -0700
Re: FizzBuzz is a trick question. Snit <usenet@gallopinginsanity.com> - 2017-08-04 11:47 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Snit <usenet@gallopinginsanity.com> - 2017-08-04 12:51 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. fr314159@gmail.com - 2017-08-04 12:57 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Steve Carroll <fretwizzer@gmail.com> - 2017-08-04 13:02 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-04 20:02 +0000
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Steve Carroll <fretwizzer@gmail.com> - 2017-08-04 13:11 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-04 20:17 +0000
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Steve Carroll <fretwizzer@gmail.com> - 2017-08-04 13:42 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. "F. Russell" <fr@random.info> - 2017-08-04 23:06 +0000
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Melzzzzz <Melzzzzz@zzzzz.com> - 2017-08-04 23:32 +0000
Re: I'm the best c coder here. Snit <usenet@gallopinginsanity.com> - 2017-08-04 14:03 -0700
Re: I'm the best c coder here. "F. Russell" <fr@random.info> - 2017-08-04 23:15 +0000
Re: I'm the best c coder here. benj <benj@nobody.net> - 2017-08-04 19:35 -0400
Re: I'm the best c coder here. "F. Russell" <fr@random.info> - 2017-08-05 16:08 +0000
Re: Fabian seldom writes code, much less test it. owl <owl@rooftop.invalid> - 2017-08-05 03:09 +0000
Re: 2 lines, 2^2 states, easily modified to 3^2 states. owl <owl@rooftop.invalid> - 2017-08-05 05:42 +0000
Re: Who'd use "x++", in a loop, to find FizzBuzzGoozKaaz ? owl <owl@rooftop.invalid> - 2017-08-05 07:30 +0000
Re: 2 lines, 2^2 states, easily modified to 3^2 states. Marek Novotny <marek.novotny@marspolar.com> - 2017-08-05 10:19 -0500
Re: 2 lines, 2^2 states, easily modified to 3^2 states. Steve Carroll <fretwizzer@gmail.com> - 2017-08-05 10:13 -0700
Re: 2 lines, 2^2 states, easily modified to 3^2 states. owl <owl@rooftop.invalid> - 2017-08-05 17:33 +0000
Re: Fabian seldom writes code, much less test it. Marek Novotny <marek.novotny@marspolar.com> - 2017-08-04 22:24 -0500
Re: Fabian seldom writes code, much less test it. "F. Russell" <fr@random.info> - 2017-08-05 13:37 +0000
Re: Fabian seldom writes code, much less test it. "F. Russell" <fr@random.info> - 2017-08-05 14:25 +0000
Re: I'm the best c coder here. owl <owl@rooftop.invalid> - 2017-08-05 03:22 +0000
Re: I'm the best c coder here. Marek Novotny <marek.novotny@marspolar.com> - 2017-08-04 22:35 -0500
Re: I'm the best c coder here. owl <owl@rooftop.invalid> - 2017-08-05 04:08 +0000
Re: I reduced Owl's 43 lines to 5. owl <owl@rooftop.invalid> - 2017-08-05 07:25 +0000
Re: Owl's FizBuzGozKaz branches 5 times more often. owl <owl@rooftop.invalid> - 2017-08-05 15:40 +0000
Re: I'm _still_ the best c coder here. owl <owl@rooftop.invalid> - 2017-08-05 06:12 +0000
Re: I'm _still_ the best c coder here. moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-08-05 22:16 +0000
Re: I increment things at the _start_ of a loop. Steve Carroll <fretwizzer@gmail.com> - 2017-08-06 11:04 -0700
Re: I increment things at the _start_ of a loop. moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-08-07 03:24 +0000
Re: I increment things at the _start_ of a loop. Snit <usenet@gallopinginsanity.com> - 2017-08-06 20:35 -0700
Re: "while ( x++ < 100 )" isn't "obscure". moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-08-07 04:59 +0000
Re: I'm the best c coder here. chrisv <chrisv@nospam.invalid> - 2017-08-07 06:59 -0500
Re: I'm the best c coder here. Steve Carroll <fretwizzer@gmail.com> - 2017-08-08 10:23 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. DFS <nospam@dfs.com> - 2017-08-04 17:56 -0400
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. "F. Russell" <fr@random.info> - 2017-08-04 23:04 +0000
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Snit <usenet@gallopinginsanity.com> - 2017-08-04 16:09 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. fellatiohornblower@renlott.org - 2017-08-04 20:13 -0400
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. "F. Russell" <fr@random.info> - 2017-08-05 13:50 +0000
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. "F. Russell" <fr@random.info> - 2017-08-05 15:23 +0000
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Snit <usenet@gallopinginsanity.com> - 2017-08-05 10:06 -0700
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Doomsdrzej <.m@nsn.s> - 2017-08-05 11:52 -0400
Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. Snit <usenet@gallopinginsanity.com> - 2017-08-05 09:55 -0700
Re: Fabian's code is always slower. Takuya Saitoh <taka0038@gmail.com> - 2017-08-06 22:37 -0700
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-04 12:38 -0700 |
| Subject | Re: Marek Novotny is a command line jockey. |
| Message-ID | <D5AA1B3F.AEB3D%usenet@gallopinginsanity.com> |
| In reply to | #425737 |
On 8/4/17, 12:03 PM, in article Jeff-Relf.Me@Aug.4--0.03pm.Seattle.2017, "<Jeff-Relf.Me @.>" <> wrote: > > You ( Marek Novotny ) presented "the best" version of FizzBuzz, > but it tells us that, for better or worse, you're a command line jockey. > You mean my AppleScript solutions do not beat his? :) -- Personal attacks from those who troll show their own insecurity. They cannot use reason to show the message to be wrong so they try to feel somehow superior by attacking the messenger. They cling to their attacks and ignore the message time and time again. <https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2017-08-03 03:12 +0000 |
| Subject | Re: My code is twice as fast as Owl's. |
| Message-ID | <szvbz003a.byu@rooftop.invalid> |
| In reply to | #425491 |
Jeff-Relf.Me wrote:
> My code is twice as fast as Owl's:
>
> Me: 17.7 MicroSeconds
> Owl: 32.3 MicroSeconds.
>
> My code:
>
> double Mark = Secs ; int i = 0 ;
> while( i++ < 100 )
> i%3 ? ( i%5 ? Sh( L"%d", i ) : Sh( L"Buz" ) )
> : i%5 ? Sh( L"Fiz" ) : Sh( L"FizBuz" );
> Mark = Secs - Mark, Sh( L"Me: %sSeconds", Prn( Mark ) );
>
> Owl's code ( for my console ):
>
> #define MAX 100
> #define FOO 3
> #define BAR 5
>
> void blah(int x){ Sh( L"%d",x);};
> void fizz(int x){ Sh( L"Fiz");};
> void buzz(int x){ Sh( L"Buz");};
> void fizzbuzz(int x){ Sh( L"FizzBuz");};
>
> Mark = Secs ;
> void (*f[])(int)={blah,fizz,buzz,fizzbuzz}; int i=0,j=0,v=0;
> for(i=1;i<=MAX;i++) {
> for(j=FOO;j<=i;j+=FOO) { if(j==i){v+=1;} }
> for(j=BAR;j<=i;j+=BAR) { if(j==i){v+=2;} } f[v](i); v=0; }
> Mark = Secs - Mark, Sh( L"Owl: %sSeconds", Prn( Mark ) );
>
> My timer:
>
> #define Tics ( QueryPerformanceCounter( ( DubInt * ) & _Tics ), _Tics )
> #define Secs ( _Secs = Tics / _Hz )
>
> typedef unsigned __int64 u64 ; typedef LARGE_INTEGER DubInt ;
> u64 _Tics, Hz ; double _Secs, _Hz ;
> QueryPerformanceFrequency( ( DubInt * ) & Hz ), _Hz = Hz ;
>
> P.S. No one would hire Fabian. Per usual, he refuses to show any code;
> instead, he mocks the interviewer's task, and insults him.
>
I fixed that code already. Use this:
anon@lowtide:~/code/fizzbuzz$ cat ff.c
#include <stdio.h>
#define MAX 100000
#define FOO 3
#define BAR 5
void blah(int x){printf("%d\n",x);};
void fizz(int x){printf("Fizz\n");};
void buzz(int x){printf("Buzz\n");};
void fizzbuzz(int x){printf("FizzBuzz\n");};
int main(int argc, char *argv[])
{
void (*f[])(int)={blah,fizz,buzz,fizzbuzz};
int i=0,j=FOO,k=BAR,v=0;
for(i=1;i<=MAX;i++)
{
for(;j<=i;j+=FOO)
{
if(j==i){v+=1;}
}
for(;k<=i;k+=BAR)
{
if(k==i){v+=2;}
}
f[v](i);
v=0;
}
return 0;
}
anon@lowtide:~/code/fizzbuzz$
I get similar speed to yours (MAX is set to 100000).
anon@lowtide:~/code/fizzbuzz$ time ./relf >relfout
real 0m0.027s
user 0m0.028s
sys 0m0.000s
anon@lowtide:~/code/fizzbuzz$ time ./ff >ffout
real 0m0.027s
user 0m0.028s
sys 0m0.000s
anon@lowtide:~/code/fizzbuzz$
I'm using this for yours:
anon@lowtide:~/code/fizzbuzz$ cat relf.c
#include <stdio.h>
int main(void)
{
int i = 0 ;
while( i++ < 100000 )
i%3 ? ( i%5 ? printf( "%d\n", i ) : printf( "Buz\n" ) )
: i%5 ? printf( "Fiz\n" ) : printf( "FizBuz\n" );
return 0;
}
anon@lowtide:~/code/fizzbuzz$
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <fr@random.info> |
|---|---|
| Date | 2017-08-02 23:04 +0000 |
| Message-ID | <oltlpv01npn@news6.newsguy.com> |
| In reply to | #425480 |
On Wed, 02 Aug 2017 11:14:45 -0700, fr314159 wrote:
>
> Write the answer without using division of any kind -- and no
> pre-computed lookup tables either.
>
Ha, ha, ha, ha, ha, ha! What a bunch of imbecilic code monkeys!
Here is how it is done WITHOUT DIVISION:
-------------------------------
Begin C Code
-------------------------------
#include <stdio.h>
int main()
{
int n, n3, n5, n15;
n=0; n3=3; n5=5; n15=15;
while (n <= 100)
{
if(n==n15) { printf("%d %s\n", n, "HarfBuzz"); n15=n15+15; n5=n5+5; n3=n3+3; }
else if(n==n5) { printf("%d %s\n", n, "Buzz"); n5=n5+5; }
else if(n==n3) { printf("%d %s\n", n, "Harf"); n3=n3+3; }
else printf("%d\n", n);
n=n+1;
// printf("%d %d %d
}
return 0;
}
-------------------------------------
End of C Code
-------------------------------------
I have eliminated division, which takes a LOT of clock cycles,
in favor of simple addition, which can be accomplished in one or
two clock cycles.
This code is only a template for assembly code.
But we could still improve things. We could use variable values
instead of constants, which would force the compiler NOT to use
immediate values, and we could use the "register" directive which
would force the compiler to put everything in the CPU registers.
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <fr@random.info> |
|---|---|
| Date | 2017-08-02 23:25 +0000 |
| Message-ID | <oltn0r02d0b@news3.newsguy.com> |
| In reply to | #425496 |
On Wed, 02 Aug 2017 23:04:31 +0000, F. Russell wrote: > > Here is how it is done WITHOUT DIVISION: > Furthermore, my fantastic code can be scaled to accommodate any set of prime factors. In this case, 3 and 5 are prime. But can your code be simply extended for the case of 3, 5, and 11? My code can be simply extended, using NO DIVISION, to accommodate any set of prime factors: i, j, k ... and their multiplicative combinations: i*j, j*k, i*k, i*j*k ... Whew baby! I'm glad that I didn't apply for that job. I would have bombed the interview for sure. Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2017-08-03 01:50 +0000 |
| Message-ID | <azv9399ba.b88@rooftop.invalid> |
| In reply to | #425500 |
F. Russell <fr@random.info> wrote:
> On Wed, 02 Aug 2017 23:04:31 +0000, F. Russell wrote:
>
>>
>> Here is how it is done WITHOUT DIVISION:
>>
>
> Furthermore, my fantastic code can be scaled to accommodate
> any set of prime factors.
>
> In this case, 3 and 5 are prime. But can your code be simply
> extended for the case of 3, 5, and 11?
>
> My code can be simply extended, using NO DIVISION, to accommodate
> any set of prime factors: i, j, k ... and their multiplicative
> combinations: i*j, j*k, i*k, i*j*k ...
>
> Whew baby! I'm glad that I didn't apply for that job. I would
> have bombed the interview for sure.
>
> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
>
#include <stdio.h>
#define MAX 100000
#define FOO 3
#define BAR 5
#define GAH 11
void blah(int x){printf("%d\n",x);};
void fizz(int x){printf("Fizz\n");};
void buzz(int x){printf("Buzz\n");};
void fizzbuzz(int x){printf("FizzBuzz\n");};
void gooz(int x){printf("Gooz\n");};
void fizzgooz(int x){printf("FizzGooz\n");};
void buzzgooz(int x){printf("BuzzGooz\n");};
void fizzbuzzgooz(int x){printf("FizzBuzzGooz\n");};
int main(int argc, char *argv[])
{
void (*f[])(int)={blah,fizz,buzz,fizzbuzz,
gooz,fizzgooz,buzzgooz,fizzbuzzgooz};
int i=0,j=FOO,k=BAR,l=GAH,v=0;
for(i=1;i<=MAX;i++)
{
for(;j<=i;j+=FOO){if(j==i){v+=1;}}
for(;k<=i;k+=BAR){if(k==i){v+=2;}}
for(;l<=i;l+=GAH){if(l==i){v+=4;}}
f[v](i);
v=0;
}
return 0;
}
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2017-08-03 04:41 +0000 |
| Subject | Re: Fabian's code is always slower. |
| Message-ID | <zcxb3ab093t.ab3@rooftop.invalid> |
| In reply to | #425496 |
Jeff-Relf.Me wrote:
> I get the following results, 100 thousand runs, but it varies:
>
> Me: 19.3 MilliSeconds
> Owl: 18.5 MilliSeconds
> Fabian: 24.2 MilliSeconds
>
> ScreenShot: http://Jeff-Relf.Me/FizBuz.PNG
>
> Fabian's code is always slower.
> Owl's is usually faster, but not always.
> My code is the most readable/maintainable.
>
> Branimir Maksimovic's code wasn't timed,
> and it's not readable/maintainable/relatable.
>
I'll time Melzzzzz's code if I can get tasm to work.
Try this (less on the stack):
anon@lowtide:~/code/fizzbuzz$ cat hh.c
#include <stdio.h>
#define MAX 1000000
#define FOO 3
#define BAR 5
int x=0;
void blah(void){printf("%d\n",x);};
void fizz(void){printf("Fizz\n");};
void buzz(void){printf("Buzz\n");};
void fizzbuzz(void){printf("FizzBuzz\n");};
int main(int argc, char *argv[])
{
void (*f[])(void)={blah,fizz,buzz,fizzbuzz};
int i=0,j=FOO,k=BAR,v=0;
for(i=1;i<=MAX;i++)
{
for(;j<=i;j+=FOO)
{
if(j==i){v+=1;}
}
for(;k<=i;k+=BAR)
{
if(k==i){v+=2;}
}
x=i;
f[v]();
v=0;
}
return 0;
}
anon@lowtide:~/code/fizzbuzz$
Seems to be consistently faster than my previous code.
anon@lowtide:~/code/fizzbuzz$ cat run
#!/bin/bash
time ./ff >ffout
time ./hh >hhout
anon@lowtide:~/code/fizzbuzz$ ./run
real 0m0.152s
user 0m0.140s
sys 0m0.008s
real 0m0.083s
user 0m0.080s
sys 0m0.000s
anon@lowtide:~/code/fizzbuzz$ ./run
real 0m0.124s
user 0m0.120s
sys 0m0.000s
real 0m0.076s
user 0m0.072s
sys 0m0.000s
anon@lowtide:~/code/fizzbuzz$ ./run
real 0m0.145s
user 0m0.128s
sys 0m0.016s
real 0m0.121s
user 0m0.104s
sys 0m0.012s
anon@lowtide:~/code/fizzbuzz$
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2017-08-03 05:17 +0000 |
| Subject | Re: Fabian's code is always slower. |
| Message-ID | <azb3abafio3.ap@rooftop.invalid> |
| In reply to | #425557 |
owl <owl@rooftop.invalid> wrote: > > Seems to be consistently faster than my previous code. > > anon@lowtide:~/code/fizzbuzz$ cat run > #!/bin/bash > time ./ff >ffout > time ./hh >hhout > anon@lowtide:~/code/fizzbuzz$ ./run > > real 0m0.152s > user 0m0.140s > sys 0m0.008s > > real 0m0.083s > user 0m0.080s > sys 0m0.000s > anon@lowtide:~/code/fizzbuzz$ ./run > > real 0m0.124s > user 0m0.120s > sys 0m0.000s > > real 0m0.076s > user 0m0.072s > sys 0m0.000s > anon@lowtide:~/code/fizzbuzz$ ./run > > real 0m0.145s > user 0m0.128s > sys 0m0.016s > > real 0m0.121s > user 0m0.104s > sys 0m0.012s > anon@lowtide:~/code/fizzbuzz$ > Note: MAX is 1,000,000 for these.
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2017-08-03 05:57 +0000 |
| Subject | Re: What's easier to read/maintain ? |
| Message-ID | <azb003ab.je3@rooftop.invalid> |
| In reply to | #425557 |
In comp.os.linux.advocacy Jeff-Relf.Me wrote: > The I/O is the limiting factor, not my "i%3"; > also, you ( Owl ) making "x" global, > instead of passing it on the stack, makes _no_ difference. I think it does. 100000 function calls is a lot of pushing and popping of args. The new code consistently runs faster. There is no other difference in the code. > Fabian's code is slower only because he "prints" more. > > So, the _only_ question is: What's easier to read/maintain ? > > A: > > int i = 0 ; > while( i++ < 100 ) > i%3 ? ( i%5 ? printf( "%d\n", i ) : printf( "Buz\n" ) ) > : i%5 ? printf( "Fiz\n" ) : printf( "FizBuz\n" ); > > Or B: > > int i = 0, Fiz, Buz ; > while( i++ < 100 ) Fiz = !(i%3), Buz = !(i%5), printf( > Fiz && Buz ? "FizBuz\n" : Fiz ? "Fiz\n" : Buz ? "Buz\n" : "%d\n", i ); > > I like A. > That may be, but I think mine is more readable/flexible/maintainable. > Branimir Maksimovic's assembly code is a _bad _joke. > > I'm the _only_ one who can/did show a screenshot; to wit: > > http://Jeff-Relf.Me/FizBuz.PNG > Live action, baby. https://vid.me/A6GT2
[toc] | [prev] | [next] | [standalone]
| From | fr314159@gmail.com |
|---|---|
| Date | 2017-08-03 08:21 -0700 |
| Subject | Re: Fabian's code is always slower. |
| Message-ID | <b89f549c-802c-486b-9bc0-42573c320cc0@googlegroups.com> |
| In reply to | #425496 |
On Wednesday, August 2, 2017 at 11:48:31 PM UTC-4, Jeff-Relf.Me wrote:
>
>
> Owl's is usually faster,
>
His code? Ha, ha, ha, ha, ha, ha, ha, ha, ha!
Until I proposed the idea, he never would have dreamed in
a milliion years to do it without division.
There are differences between monkeys and humans.
but not always.
> My code is the most readable/maintainable.
>
> Branimir Maksimovic's code wasn't timed,
> and it's not readable/maintainable/relatable.
>
> Me:
>
> double Me = Secs ; int i = 0 ;
> while( i++ < 100000 )
> i%3 ? ( i%5 ? Sh( L"%d", i ) : Sh( L"Buz" ) )
> : i%5 ? Sh( L"Fiz" ) : Sh( L"FizBuz" );
> Me = Secs - Me ;
>
> Owl:
> #define MAX 100000
> #define FOO 3
> #define BAR 5
>
> void blah(int x){ Sh( L"%d",x);};
> void fizz(int x){ Sh( L"Fiz");};
> void buzz(int x){ Sh( L"Buz");};
> void fizzbuzz(int x){ Sh( L"FizzBuz");};
>
> double Owl = Secs ;
> void (*f[])(int)={blah,fizz,buzz,fizzbuzz};
>
> i=0 ; int j=FOO,k=BAR,v=0;
> for(i=1;i<=MAX;i++) {
> for(;j<=i;j+=FOO) { if(j==i){v+=1;} }
> for(;k<=i;k+=BAR) { if(k==i){v+=2;} }
> f[v](i); v=0; }
>
> Owl = Secs - Owl ;
>
> Fabian:
>
> double Fabian = Secs ; int n, n3, n5, n15; n=0; n3=3; n5=5; n15=15;
>
> while ( n <= 100000 ) {
> if(n==n15) { Sh( L"%d %s", n, L"HarfBuzz"); n15=n15+15; n5=n5+5; n3=n3+3; }
> else if(n==n5) { Sh( L"%d %s", n, L"Buzz"); n5=n5+5; }
> else if(n==n3) { Sh( L"%d %s", n, L"Harf"); n3=n3+3; }
> else Sh( L"%d", n); n=n+1; }
>
> Fabian = Secs - Fabian ;
>
> Sh( L"Me: %sSeconds", Prn( Me ) );
> Sh( L"Owl: %sSeconds", Prn( Owl ) );
> Sh( L"Fabian: %sSeconds", Prn( Fabian ) ); ShBot();
[toc] | [prev] | [next] | [standalone]
| From | Steve Carroll <fretwizzer@gmail.com> |
|---|---|
| Date | 2017-08-03 09:24 -0700 |
| Subject | Re: Fabian's code is always slower. |
| Message-ID | <45119882-47cf-4c9c-a531-8b8bb0a26ee7@googlegroups.com> |
| In reply to | #425628 |
On Thursday, August 3, 2017 at 9:21:33 AM UTC-6, fr31...@gmail.com wrote: > On Wednesday, August 2, 2017 at 11:48:31 PM UTC-4, Jeff-Relf.Me wrote: > > > > > > > Owl's is usually faster, > > > > His code? Ha, ha, ha, ha, ha, ha, ha, ha, ha! > > Until I proposed the idea, he never would have dreamed in > a milliion years to do it without division. Why wouldn't he have?
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2017-08-03 18:41 +0000 |
| Subject | Re: Fabian's code is always slower. |
| Message-ID | <axb2abo00a.a@rooftop.invalid> |
| In reply to | #425628 |
fr314159@gmail.com wrote: > On Wednesday, August 2, 2017 at 11:48:31 PM UTC-4, Jeff-Relf.Me wrote: > >> >> >> Owl's is usually faster, >> > > His code? Ha, ha, ha, ha, ha, ha, ha, ha, ha! > > Until I proposed the idea, he never would have dreamed in > a milliion years to do it without division. > > There are differences between monkeys and humans. > Fabtard, I used addition because you demanded a solution that did not use division. I agree that my first instinct would be to use modulo, and it's only about 10% slower that way. BTW, still waiting on your code for three values. Try to do it without copying mine.
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-03 13:49 -0700 |
| Message-ID | <D5A8DA78.AE91F%usenet@gallopinginsanity.com> |
| In reply to | #425496 |
On 8/2/17, 4:04 PM, in article oltlpv01npn@news6.newsguy.com, "F. Russell"
<fr@random.info> wrote:
> On Wed, 02 Aug 2017 11:14:45 -0700, fr314159 wrote:
>
>>
>> Write the answer without using division of any kind -- and no
>> pre-computed lookup tables either.
>>
>
> Ha, ha, ha, ha, ha, ha! What a bunch of imbecilic code monkeys!
>
> Here is how it is done WITHOUT DIVISION:
>
> -------------------------------
> Begin C Code
> -------------------------------
> #include <stdio.h>
>
> int main()
> {
> int n, n3, n5, n15;
>
> n=0; n3=3; n5=5; n15=15;
>
> while (n <= 100)
> {
> if(n==n15) { printf("%d %s\n", n, "HarfBuzz"); n15=n15+15; n5=n5+5; n3=n3+3; }
> else if(n==n5) { printf("%d %s\n", n, "Buzz"); n5=n5+5; }
> else if(n==n3) { printf("%d %s\n", n, "Harf"); n3=n3+3; }
> else printf("%d\n", n);
> n=n+1;
> // printf("%d %d %d
> }
> return 0;
> }
>
> -------------------------------------
> End of C Code
> -------------------------------------
>
> I have eliminated division, which takes a LOT of clock cycles,
> in favor of simple addition, which can be accomplished in one or
> two clock cycles.
>
> This code is only a template for assembly code.
>
> But we could still improve things. We could use variable values
> instead of constants, which would force the compiler NOT to use
> immediate values, and we could use the "register" directive which
> would force the compiler to put everything in the CPU registers.
>
>
Tried it... in AppleScript which is going to be PAINFULLY slow:
set howMany to 10000
set responseList to {""} as list
repeat with loop from 0 to howMany by 15
set responseList to responseList ¬
& loop + 1 & return ¬
& loop + 2 & return ¬
& "Fizz" & return ¬
& loop + 4 & return ¬
& "Buzz" & return ¬
& "Fizz" & return ¬
& loop + 7 & return ¬
& loop + 8 & return ¬
& "Fizz" & return ¬
& "Buzz" & return ¬
& loop + 11 & return ¬
& "Fizz" & return ¬
& loop + 13 & return ¬
& loop + 14 & return ¬
& "FizzBuzz" & return
end repeat
do shell script "echo " & (items 1 through (howMany) of responseList as
string) & " > /Users/snit/Desktop/FizzBuzz2.txt"
10 seconds. I am sure what you and Owl are doing would be MUCH faster. But
that is one third the time when I did it using division:
set howMany to 10000
set responseList to {""} as list
repeat with loop from 1 to howMany
if loop / 15 = (round (loop / 15)) then
set responseList to responseList & "FizzBuzz" & return
else if loop / 3 = (round (loop / 3)) then
set responseList to responseList & "Fizz" & return
else if loop / 5 = (round (loop / 5)) then
set responseList to responseList & "Buzz" & return
else
set responseList to responseList & loop & return
end if
end repeat
do shell script "echo " & (responseList as string) & " >
/Users/snit/Desktop/FizzBuzz1.txt"
31 seconds...
--
Personal attacks from those who troll show their own insecurity. They cannot
use reason to show the message to be wrong so they try to feel somehow
superior by attacking the messenger.
They cling to their attacks and ignore the message time and time again.
<https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-03 22:11 -0700 |
| Subject | Re: 4 lines, 4 states. |
| Message-ID | <D5A94FFB.AEA24%usenet@gallopinginsanity.com> |
| In reply to | #425662 |
On 8/3/17, 8:00 PM, in article Jeff-Relf.Me@Aug.3--8.00pm.Seattle.2017,
"<Jeff-Relf.Me @.>" <> wrote:
>
> Michael Glasser, Your (Apple)Script is:
>
> 22 confusing lines and 5 thousand times slower. ( and a pegged CPU ? )
I posted two solutions, each with a line that sets the variable of how many
numbers to calculate... could have that built in. Removing that and getting
rid of the line breaks put in for clarity and it is five lines. But, not
sure that matters. In case you care (will get wrapped by usenet I am sure):
-----
set responseList to {""} as list
repeat with loop from 0 to 100000 by 15
set responseList to responseList & loop + 1 & return & loop + 2 & return
& "Fizz" & return & loop + 4 & return & "Buzz" & return & "Fizz" & return &
loop + 7 & return & loop + 8 & return & "Fizz" & return & "Buzz" & return &
loop + 11 & return & "Fizz" & return & loop + 13 & return & loop + 14 &
return & "FizzBuzz" & return
end repeat
do shell script "echo " & (items 1 through (100000) of responseList as
string) & " > /Users/snit/Desktop/FizzBuzz2.txt"
-----
I could reduce that and put the writing into the loop... then I get four
lines:
-----
set responseList to {""} as list
repeat with loop from 0 to 100000 by 15
do shell script "echo " & loop + 1 & return & loop + 2 & return & "Fizz"
& return & loop + 4 & return & "Buzz" & return & "Fizz" & return & loop + 7
& return & loop + 8 & return & "Fizz" & return & "Buzz" & return & loop + 11
& return & "Fizz" & return & loop + 13 & return & loop + 14 & return &
"FizzBuzz" & return & " >> /Users/snit/Desktop/FizzBuzz.txt"
end repeat
-----
Then your comment about a pegged CPU? What? I said nothing about that. Not a
word.
BUT, of course, this is AppleScript and it is going to be VERY slow compared
to other languages. That is not at all in question.
> Owl, Fabian and me can do 100 thousand runs in 20 MilliSeconds.
> ScreenShot: http://Jeff-Relf.Me/FizBuz.PNG
Clearly our solution will be MASSIVELY faster, but I thought the numbers
were supposed to be REPLACED by the words... not added to them.
> For us, it doesn't matter if we use "i%3" or not,
> as the I/O is the limiting factor, not "i%3".
Yes, I suspect the I/O for macOS is slowing mine down as well, though even
without they it would be painfully slow. Not really a job handled well by
AppleScript... I was just curious.
> Assembly language wouldn't help.
> So I chose _the _most _readable option;
> to wit, these 4 lines, 4 states:
>
> int i = 0 ;
> while( i++
Your code got cut off.
--
Personal attacks from those who troll show their own insecurity. They cannot
use reason to show the message to be wrong so they try to feel somehow
superior by attacking the messenger.
They cling to their attacks and ignore the message time and time again.
<https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-03 22:47 -0700 |
| Subject | Re: 4 lines, 4 states. |
| Message-ID | <D5A9589C.AEA30%usenet@gallopinginsanity.com> |
| In reply to | #425703 |
On 8/3/17, 10:11 PM, in article D5A94FFB.AEA24%usenet@gallopinginsanity.com,
"Snit" <usenet@gallopinginsanity.com> wrote:
> On 8/3/17, 8:00 PM, in article Jeff-Relf.Me@Aug.3--8.00pm.Seattle.2017,
> "<Jeff-Relf.Me @.>" <> wrote:
>
>>
>> Michael Glasser, Your (Apple)Script is:
>>
>> 22 confusing lines and 5 thousand times slower. ( and a pegged CPU ? )
>
> I posted two solutions, each with a line that sets the variable of how many
> numbers to calculate... could have that built in. Removing that and getting
> rid of the line breaks put in for clarity and it is five lines. But, not
> sure that matters. In case you care (will get wrapped by usenet I am sure):
>
> -----
> set responseList to {""} as list
> repeat with loop from 0 to 100000 by 15
> set responseList to responseList & loop + 1 & return & loop + 2 & return
> & "Fizz" & return & loop + 4 & return & "Buzz" & return & "Fizz" & return &
> loop + 7 & return & loop + 8 & return & "Fizz" & return & "Buzz" & return &
> loop + 11 & return & "Fizz" & return & loop + 13 & return & loop + 14 &
> return & "FizzBuzz" & return
> end repeat
> do shell script "echo " & (items 1 through (100000) of responseList as
> string) & " > /Users/snit/Desktop/FizzBuzz2.txt"
> -----
>
>
> I could reduce that and put the writing into the loop... then I get four
> lines:
>
> -----
> set responseList to {""} as list
> repeat with loop from 0 to 100000 by 15
> do shell script "echo " & loop + 1 & return & loop + 2 & return & "Fizz"
> & return & loop + 4 & return & "Buzz" & return & "Fizz" & return & loop + 7
> & return & loop + 8 & return & "Fizz" & return & "Buzz" & return & loop + 11
> & return & "Fizz" & return & loop + 13 & return & loop + 14 & return &
> "FizzBuzz" & return & " >> /Users/snit/Desktop/FizzBuzz.txt"
> end repeat
> -----
>
> Then your comment about a pegged CPU? What? I said nothing about that. Not a
> word.
>
> BUT, of course, this is AppleScript and it is going to be VERY slow compared
> to other languages. That is not at all in question.
Just tested 100,000: running from Script Editor I got bored waiting... was
taking minutes. Even running as a saved application it took 65 seconds! And,
given that I calculate 15 at a time my method handles 100,005 lines, which
is not what was asked for so in that way my program is broken.
In case you want to watch this amazing spectacle (time sped up to avoid
boring everyone to tears):
<https://youtu.be/Ak50RS9Y2xw>
Took 63 seconds for this run... CPU(s) *NOT* pegged. It looks like the app
is not multi-threaded or whatever... does not go above 100% of a single CPU.
Might be faster if it did. :)
...
--
Personal attacks from those who troll show their own insecurity. They cannot
use reason to show the message to be wrong so they try to feel somehow
superior by attacking the messenger.
They cling to their attacks and ignore the message time and time again.
<https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-03 22:52 -0700 |
| Subject | Re: 4 lines, 4 states. |
| Message-ID | <D5A959A5.AEA34%usenet@gallopinginsanity.com> |
| In reply to | #425703 |
On 8/3/17, 10:31 PM, in article Jeff-Relf.Me@Aug.3--10.31pm.Seattle.2017,
"<Jeff-Relf.Me @.>" <> wrote:
>
> You ( MichaelGlasser ) replied ( to me ):
>> Then your comment about a pegged CPU? What?
>
> It was a question, not a comment.
Well, the answer is no... does not peg. Goes up to about 100% (with multiple
CPUs of course programs can go higher than that).
>> I said nothing about that. Not a word.
>
> Yes, but does it peg the CPU ?
Nope. Sorry for misunderstanding -- though you were saying it DOES peg the
CPU. Not at all. If it did it might be a bit LESS dog slow. :)
>> BUT, of course, this is AppleScript and it is going to be
>> VERY slow compared to other languages.
>> That is not at all in question.
>
> 5 thousand times slower, 8 times the lines, and more complex.
Well, the logic can be changed... and lines reduced, but, sure, it is going
to be MUCH slower. It is easier for non-programmers to read and write, but
it SUCKS if your goal is fast calculations!
<https://youtu.be/Ak50RS9Y2xw>
That is the splendor of my solution. :)
>>> So I chose _the _most _readable option;
>>> to wit, these 4 lines, 4 states:
>>>
>>> int i = 0 ;
>>> while( i++ < 100000 )
>>> i%3 ? ( i%5 ? Sh( L"%d", i ) : Sh( L"Buz" ) )
>>> : i%5 ? Sh( L"Fiz" ) : Sh( L"FizBuz" );
>>
>> Your code got cut off.
>
> Your newsreader is decades old, right ?
2008
> Why not upgrade it ?
I might... will likely have to with the next OS update. :)
> GoogleGroups/FireFox handles it fine, see:
>
> https://groups.google.com/d/msg/sci.physics/8DISFYs-DSo/b8ji_8KyCQAJ
Yup... my newsreader sucks.
Anyway, what about yours NOT having the numbers where it is not supposed to?
Maybe you are keeping that so at least in one way my solution is better? :)
--
Personal attacks from those who troll show their own insecurity. They cannot
use reason to show the message to be wrong so they try to feel somehow
superior by attacking the messenger.
They cling to their attacks and ignore the message time and time again.
<https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | Steve Carroll <fretwizzer@gmail.com> |
|---|---|
| Date | 2017-08-04 08:54 -0700 |
| Subject | Re: Mozilla ThunderBird. |
| Message-ID | <883d4ab7-4208-4ef7-8f16-f56678e4f1f1@googlegroups.com> |
| In reply to | #425705 |
On Friday, August 4, 2017 at 1:35:29 AM UTC-6, Jeff-Relf.Me wrote: > > Mozilla ThunderBird is good, and you can write extensions for it, > using JavaScript, or change the look, using CSS. Very powerful. > Most people can't be bothered to learn it, of course. JavaScript and CSS are the red headed step children of computing.
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-04 10:43 -0700 |
| Subject | Re: Mozilla ThunderBird. |
| Message-ID | <D5AA006B.AEAF4%usenet@gallopinginsanity.com> |
| In reply to | #425705 |
On 8/4/17, 12:35 AM, in article Jeff-Relf.Me@Aug.4--0.35am.Seattle.2017, "<Jeff-Relf.Me @.>" <> wrote: > > You ( Michael Glasser ) replied ( to me ): >>> GoogleGroups/FireFox [ display my posts ] fine, see: >>> https://groups.google.com/d/msg/sci.physics/8DISFYs-DSo/b8ji_8KyCQAJ >> >> Yup... my newsreader sucks. > > Mozilla ThunderBird is good, and you can write extensions for it, > using JavaScript, or change the look, using CSS. Very powerful. > Most people can't be bothered to learn it, of course. I have fiddled with it... if I recall correctly it does not have smart folders that allowed me to set up rules as well as the ancient piece of garbage I now use. Could be wrong... but there was SOMETHING that was not working well for me with it. Sure I could get used to it though. > I wish you ( and everyone else ) stopped posting "signatures"; > I even hate EdProchak's tiny little "ed" sig, at then end of his posts. > But that's just me, of course. I think the standard is to be no longer than four lines or something like that... so mine is a bit long. As long as people use the proper delimiter, though, I do not mind them... pretty much just ignore them. >> Owl, Fabian and me can do 100 thousand runs in 20 MilliSeconds. >> ScreenShot: http://Jeff-Relf.Me/FizBuz.PNG >> >> what about yours NOT having the numbers where it is not supposed to? >> Maybe you are keeping that so at least in one way my solution is better? :) > > Fabian's code was the last to run; so the ScreenShot shows his verion; > His is slower because he prints more, like that; no biggie. Seems to me if you are NOT avoiding those numbers then you are not doing the task the way the kid's game is played, which I thought was the requirement... but I admit I have not even gone back to look. I largely posted the AppleScript solution to show how BAD it is in terms of speed (and how crappy of a scripter I am!) -- Personal attacks from those who troll show their own insecurity. They cannot use reason to show the message to be wrong so they try to feel somehow superior by attacking the messenger. They cling to their attacks and ignore the message time and time again. <https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-04 11:47 -0700 |
| Subject | Re: FizzBuzz is a trick question. |
| Message-ID | <D5AA0F44.AEB1A%usenet@gallopinginsanity.com> |
| In reply to | #425735 |
On 8/4/17, 11:42 AM, in article Jeff-Relf.Me@Aug.4--11.42am.Seattle.2017,
"<Jeff-Relf.Me @.>" <> wrote:
>
> You ( Michael Glasser ) replied ( to me ):
>>> Mozilla ThunderBird is good, and you can write extensions for it,
>>> using JavaScript, or change the look, using CSS. Very powerful.
>>> Most people can't be bothered to learn it, of course.
>>
>> I have fiddled with it... if I recall correctly it does not have smart
>> folders that allowed me to set up rules as well as the ancient piece of
>> garbage I now use. Could be wrong... but there was SOMETHING that was not
>> working well for me with it. Sure I could get used to it though.
>
> Getting it to work properly ( extensions, settings, CSS and all )
> would take a ( painfully ) long time, I imagine.
Could be... I only gave it a few minutes to impress me. It did not so I
moved on. But given how crappy my current client is, how old it is, and how
it is likely to die on the next OS update I suppose I should look into it
again. :)
>> I largely posted the AppleScript [ version of FizzBuzz ]
>> to show how BAD it is in terms of speed ( and how crappy
>> of a scripter I am! ).
>
> FizBuz is a trick question, designed to see if you:
> A. foolishly optimize random shit. Or:
> B. write concise, readable code.
>
> My answer: http://jeff-relf.me/FizBuz.HTM
>
One of my early efforts was this:
-------
set theList to {} as list
repeat with loop from 1 to 10000
if loop mod 15 = 0 then
set theList to theList & "FizzBuzz" & return
else if loop mod 3 = 0 then
set theList to theList & "Fizz" & return
else if loop mod 5 = 0 then
set theList to theList & "Buzz" & return
else
set theList to theList & loop & return
end if
end repeat
do shell script "echo " & theList & " >>
/Users/snit/Desktop/FizzBuzz/FizzBuzz2.txt"
-------
That is very readable... as was one that used division. If I really wanted
it to work better, though, I would have it write to file every 1000 lines or
so -- but never bothered to do that. :)
Of course if I presented that for a PROGRAMMING job they would laugh their
asses off at me and ask why I am not using an actual programming language!
--
Personal attacks from those who troll show their own insecurity. They cannot
use reason to show the message to be wrong so they try to feel somehow
superior by attacking the messenger.
They cling to their attacks and ignore the message time and time again.
<https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | Snit <usenet@gallopinginsanity.com> |
|---|---|
| Date | 2017-08-04 12:51 -0700 |
| Subject | Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. |
| Message-ID | <D5AA1E4B.AEB45%usenet@gallopinginsanity.com> |
| In reply to | #425747 |
On 8/4/17, 12:31 PM, in article Jeff-Relf.Me@Aug.4--0.31pm.Seattle.2017, "<Jeff-Relf.Me @.>" <> wrote: > > You ( Michael Glasser ) replied ( to me ): >> If I really wanted it to work better, though, >> I would have it write to file every 1000 lines or so >> -- but never bothered to do that. :) > > Even that optimization would do more harm than good, I think. > Try it, and time it; it wouldn't be faster, I bet. Did not try it, but when I did 10,000 it did it, um, was going to say "fairly quickly" but that is not the right phrase... in less time than it takes to have a pizza delivered. :) I think it was 9 seconds or so. When I went up to 100,000, though, I expected 90 seconds or so... but waited for over five and then gave up on it. AppleScript is known for memory leaks and other nonsense so I am guessing it pretty much died. If I care I can check again... >> Of course if I presented that for a PROGRAMMING job >> they would laugh their asses off at me and ask why >> I am not using an actual programming language! > > Well... it tells them: > > Michael Glasser is an AppleScript guy. And not a good one, at that! > Steve Carroll is all about JavaScript. And WordPress. Surprised he did not point to a WordPress plugin to try it. :) > Marek Novotny is a command line jockey. He clearly has some good skills. No doubt. > Branimir Maksimovic is a DownToTheMetal Assembly Language guy. > > Owl, Fabian and Jeff Relf are c programmers. At the very least Owl seems to know what he is doing, too. What I find funny is how Owl and Marek, who both EASILY blow me away with their scripting / programming abilities (not even a close call here) seem hell-bent on proving their worth by showing they can do things I cannot. Um, yeah, this simple exercise is enough to see that. Not only do I use a tool that is crappy for the job (assuming you want more than 100) but I do not even use it well! -- Personal attacks from those who troll show their own insecurity. They cannot use reason to show the message to be wrong so they try to feel somehow superior by attacking the messenger. They cling to their attacks and ignore the message time and time again. <https://youtu.be/H4NW-Cqh308>
[toc] | [prev] | [next] | [standalone]
| From | fr314159@gmail.com |
|---|---|
| Date | 2017-08-04 12:57 -0700 |
| Subject | Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc. |
| Message-ID | <feae2868-c0a7-4ff5-ae71-0ad427d8028f@googlegroups.com> |
| In reply to | #425747 |
On Friday, August 4, 2017 at 3:31:42 PM UTC-4, Jeff-Relf.Me wrote: > > ... are c programmers. > How many times do I have to say it before you brain-dead clowns get the message? Programming is NOT coding. Programming is the analysis and solution of problems through the application of computer science principles. It does not and cannot depend on any language. Coding is a SECONDARY activity that takes place AFTER the problem has been analyzed and solved. But I am wasting my breath. You jerks cannot learn.
[toc] | [prev] | [next] | [standalone]
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
Back to top | Article view | comp.os.linux.advocacy
csiph-web