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


Groups > comp.os.linux.advocacy > #425480 > unrolled thread

Re: FizzBuzz: an Interview Question ( for programmers ).

Started byfr314159@gmail.com
First post2017-08-02 11:14 -0700
Last post2017-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.


Contents

  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 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →


#425848 — Re: I'm the best c coder here.

Fromowl <owl@rooftop.invalid>
Date2017-08-05 03:22 +0000
SubjectRe: I'm the best c coder here.
Message-ID<pkbzb34a.b933u0@rooftop.invalid>
In reply to#425772
In comp.os.linux.advocacy Jeff-Relf.Me wrote:
> I'm the best c coder here, I think.
> 

Jeff Rofl.

> Fabian optimized something he shouldn't have;
> the I/O is thee only limiting factor, not "x%3".
> 
> Also, he failed to test the code he wrote,
> and _failed_ to compare it with mine.
> Usually, he fails to write _any_ code, much less test it.
> 
> Owl failed to write concise, readable code;

Says the man who chose to use the least readable construct
in the C language.

> instead, he foolishly optimized the wrong thing.
> 

I "optimized" only because that is what Fabtard asked for.
Otherwise I would have used modulo. 

> Marek Novotny's c was better than Owl's or Fabian's, 
> but it wasn't as concise|readable as mine, I think.
> Initially, he chose bash, not c.

My code is far more "maintainable" than yours.  It is trivial
to expand it to use three or four values with no change
in complexity for the decision logic, and using an array of
function pointers instead of simply pointing printf() to an
array of strings opens all kinds of possibilities. 

[toc] | [prev] | [next] | [standalone]


#425850 — Re: I'm the best c coder here.

FromMarek Novotny <marek.novotny@marspolar.com>
Date2017-08-04 22:35 -0500
SubjectRe: I'm the best c coder here.
Message-ID<ZPednQQM1d-coBjEnZ2dnUU7-emdnZ2d@giganews.com>
In reply to#425848
On 2017-08-05, owl <owl@rooftop.invalid> wrote:
> In comp.os.linux.advocacy Jeff-Relf.Me wrote:
>> I'm the best c coder here, I think.
>> 
>
> Jeff Rofl.
>
>> Fabian optimized something he shouldn't have;
>> the I/O is thee only limiting factor, not "x%3".
>> 
>> Also, he failed to test the code he wrote,
>> and _failed_ to compare it with mine.
>> Usually, he fails to write _any_ code, much less test it.
>> 
>> Owl failed to write concise, readable code;
>
> Says the man who chose to use the least readable construct
> in the C language.
>
>> instead, he foolishly optimized the wrong thing.
>> 
>
> I "optimized" only because that is what Fabtard asked for.
> Otherwise I would have used modulo. 
>
>> Marek Novotny's c was better than Owl's or Fabian's, 
>> but it wasn't as concise|readable as mine, I think.
>> Initially, he chose bash, not c.
>
> My code is far more "maintainable" than yours.  It is trivial
> to expand it to use three or four values with no change
> in complexity for the decision logic, and using an array of
> function pointers instead of simply pointing printf() to an
> array of strings opens all kinds of possibilities. 

Could you re-post yours? I've been away a while and just cleared
everything and don't want to go through them all. Curious to see what
you did. 

-- 
Marek Novotny
https://github.com/marek-novotny

[toc] | [prev] | [next] | [standalone]


#425851 — Re: I'm the best c coder here.

Fromowl <owl@rooftop.invalid>
Date2017-08-05 04:08 +0000
SubjectRe: I'm the best c coder here.
Message-ID<pi3abz.3g88x8@rooftop.invalid>
In reply to#425850
Marek Novotny <marek.novotny@marspolar.com> wrote:
> On 2017-08-05, owl <owl@rooftop.invalid> wrote:
>> In comp.os.linux.advocacy Jeff-Relf.Me wrote:
>>> I'm the best c coder here, I think.
>>> 
>>
>> Jeff Rofl.
>>
>>> Fabian optimized something he shouldn't have;
>>> the I/O is thee only limiting factor, not "x%3".
>>> 
>>> Also, he failed to test the code he wrote,
>>> and _failed_ to compare it with mine.
>>> Usually, he fails to write _any_ code, much less test it.
>>> 
>>> Owl failed to write concise, readable code;
>>
>> Says the man who chose to use the least readable construct
>> in the C language.
>>
>>> instead, he foolishly optimized the wrong thing.
>>> 
>>
>> I "optimized" only because that is what Fabtard asked for.
>> Otherwise I would have used modulo. 
>>
>>> Marek Novotny's c was better than Owl's or Fabian's, 
>>> but it wasn't as concise|readable as mine, I think.
>>> Initially, he chose bash, not c.
>>
>> My code is far more "maintainable" than yours.  It is trivial
>> to expand it to use three or four values with no change
>> in complexity for the decision logic, and using an array of
>> function pointers instead of simply pointing printf() to an
>> array of strings opens all kinds of possibilities. 
> 
> Could you re-post yours? I've been away a while and just cleared
> everything and don't want to go through them all. Curious to see what
> you did. 
> 

Here's a version testing four primes over ten million iterations.
Jeff whined about using Fabtard optimization, so went back to
modulo in the main loop.

anon@lowtide:~/code/fizzbuzz$ cat pp.c
#include <stdio.h>

#define MAX 10000000
#define FOO 3
#define BAR 5
#define GAH 571 
#define DZZ 897 

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");}
void kaaz(int x){printf("Kaaz\n");}
void fizzkaaz(int x){printf("FizzKaaz\n");}
void buzzkaaz(int x){printf("BuzzKaaz\n");}
void fizzbuzzkaaz(int x){printf("FizzBuzzKaaz\n");}
void goozkaaz(int x){printf("GoozKaaz\n");}
void fizzgoozkaaz(int x){printf("FizzGoozKaaz\n");}
void buzzgoozkaaz(int x){printf("BuzzGoozKaaz\n");}
void fizzbuzzgoozkaaz(int x){printf("FizzBuzzGoozKaaz\n");}

int main(int argc, char *argv[])
{
   void (*f[])(int)={blah,fizz,buzz,fizzbuzz,
                     gooz,fizzgooz,buzzgooz,fizzbuzzgooz,
                     kaaz,fizzkaaz,buzzkaaz,fizzbuzzkaaz,
                     goozkaaz,fizzgoozkaaz,buzzgoozkaaz,fizzbuzzgoozkaaz};

   int i=0,v=0;
   for(i=1;i<=MAX;i++)
   {
      if(i%FOO==0){v+=1;}
      if(i%BAR==0){v+=2;}
      if(i%GAH==0){v+=4;}
      if(i%DZZ==0){v+=8;}
      f[v](i);
      v=0;
   }
   return 0;
}

anon@lowtide:~/code/fizzbuzz$

Hits only three times for all four over 10,000,000:

anon@lowtide:~/code/fizzbuzz$ time ./pp >ppout

real    0m0.798s
user    0m0.704s
sys     0m0.092s
anon@lowtide:~/code/fizzbuzz$ grep -C5 FizzBuzzGoozKaaz ppout
Buzz
2560931
Fizz
2560933
2560934
FizzBuzzGoozKaaz
2560936
2560937
Fizz
2560939
Buzz
--
Buzz
5121866
Fizz
5121868
5121869
FizzBuzzGoozKaaz
5121871
5121872
Fizz
5121874
Buzz
--
Buzz
7682801
Fizz
7682803
7682804
FizzBuzzGoozKaaz
7682806
7682807
Fizz
7682809
Buzz
anon@lowtide:~/code/fizzbuzz$

[toc] | [prev] | [next] | [standalone]


#425895 — Re: I reduced Owl's 43 lines to 5.

Fromowl <owl@rooftop.invalid>
Date2017-08-05 07:25 +0000
SubjectRe: I reduced Owl's 43 lines to 5.
Message-ID<azb3a009ba.38@rooftop.invalid>
In reply to#425851
In comp.os.linux.advocacy Jeff-Relf.Me wrote:
> You ( Owl ) wrote:
> > Jeff whined about using Fabtard's optimizations...
> 
> "Fabtard" doesn't know that his his code was slower than mine.
> Your code was the same speed as mine, but more convoluted.
> 
> > Here's a version testing four primes over ten million iterations.
> 
> We don't need any more timed runs, sorry;
> already, we know that I/O is _thee _only limiting factor.
> 

"ten million" is not a time.  Sometimes is takes a lot of iterations:
http://imgur.com/a/wXPt9
    
> Moving to 4 primes, it's:  [ I reduced your 43 lines to 5 ]
> 

What difference does that make?  I can reformat my source and have most
of it on one line.  Besides, my code runs faster than yours. LALALALA.
What you did is make a mess.


>   char *Say[16] = { "%d", "Fiz", "Buz", "FizBuz", "Goz", "FizGoz",
>     "BuzGoz", "FizBuzGoz", "Kaz", "FizKaz", "BuzKaz", "FizBuzKaz", 
>     "GozKaz", "FizGozKaz", "BuzGozKaz", "FizBuzGozKaz" };   int x = 0 ;
>   while ( x++ < 100 ) printf(", "),
>     printf( Say[ 8*!(x%11) + 4*!(x%7) + 2*!(x%5) + !(x%3) ], x );
> 

It's a good thing that you know that all you will ever want to do
is printf().

[toc] | [prev] | [next] | [standalone]


#425935 — Re: Owl's FizBuzGozKaz branches 5 times more often.

Fromowl <owl@rooftop.invalid>
Date2017-08-05 15:40 +0000
SubjectRe: Owl's FizBuzGozKaz branches 5 times more often.
Message-ID<pq12jbv903ab.h3uu4@rooftop.invalid>
In reply to#425895
In comp.os.linux.advocacy Jeff-Relf.Me wrote:
> You ( Owl ) replied ( to me ):
> > > Moving to 4 primes, it's:  [ I reduced your 43 lines to 5 ]
> > > 
> > >   char *Say[16] = { "%d", "Fiz", "Buz", "FizBuz", "Goz", "FizGoz",
> > >     "BuzGoz", "FizBuzGoz", "Kaz", "FizKaz", "BuzKaz", "FizBuzKaz", 
> > >     "GozKaz", "FizGozKaz", "BuzGozKaz", "FizBuzGozKaz" };   int x = 0 ;
> > >   while ( x++ < 100 ) printf(", "),
> > >     printf( Say[ 8*!(x%11) + 4*!(x%7) + 2*!(x%5) + !(x%3) ], x );
> > 
> > What difference does that make?  I can reformat my source and have most
> > of it on one line.  Besides, my code runs faster than yours.  LALALALA.
> > What you did is make a mess.
> 
> Stop lying to yourself, 
> I reduced your 43 lines, 74 columns to: 5 lines, 71 columns, indented.
> 
> Your FizBuzGozKaz isn't faster ( or slower ) than mine; note:
> 

My tests show that it is.

>   1.  You branch 5 times more often.
> 

The regularity of this pattern means that the CPU's branch
prediction will have no trouble.

>   2.  I call one function.  You call 16 different functions, 

In your latest example, you call printf() twice for each iteration.

>       each of which calls another funtion, pushing the stack.
> 

All but one of the printfs acts on a string literal.  The compiler
could inline them. 

> > all you will ever want to do is printf().
> 
> Right, UnlessAndUntil you convince me otherwise;
> I won't be holding my breath.
> 

I already showed you a good use:  3,5,571,897 don't hit on all four
until you're at about 2.5 million iterations; 3,571,891,1277 don't all
hit until nearly 650 millon iterations.  The popups notify you that you
have a hit at a certain level and keep you from having to grep after
every run when you're testing various sets of numbers at various counts:

./foo a b c d 1000
./foo a b c d 10000
./foo a b c d 100000
./foo a b c d 1000000
...

You can keep upping the count until you get a popup.  You could easily
make the popup conditional by passing an option in argv, and kill a run
as soon as you get a popup, then run the program again without popups
to get all values without interaction.

[toc] | [prev] | [next] | [standalone]


#425878 — Re: I'm _still_ the best c coder here.

Fromowl <owl@rooftop.invalid>
Date2017-08-05 06:12 +0000
SubjectRe: I'm _still_ the best c coder here.
Message-ID<zbsg3av90.ar@rooftop.invalid>
In reply to#425848
In comp.os.linux.advocacy Jeff-Relf.Me wrote:
> You ( Owl ) replied ( to me ):
> > > Marek Novotny's c was better than Owl's or Fabian's, 
> > > but it wasn't as concise|readable as mine, I think.
> > > Initially, he chose bash, not c.
> > 
> > My code is far more "maintainable" than yours.
> 
> No one would agree with you, no one.
> not compared to my:  http://Jeff-Relf.Me/FizBuz.HTM
> 
> > It's trivial to expand [ my FiZBuz ] to use three or four values
> > with no change in complexity for the decision logic, 
> > and using an array of function pointers 
> > instead of simply pointing printf() to an
> > array of strings opens all kinds of possibilities. 
> 
> Your shit was 28 lines, and very convolulted/confusing.

LOL!  It's not confusing.  It does exactly what you are
doing below, only points into an array of function pointers
instead of an array of char pointers.


> Mine is 2 lines, 2^2 states, and easily modified to 2^3 states,
> via: 4*!(x%3) + 2*!(x%5) + !(x%7).
> 
>   int x = 0 ;  char *Say[4] = { "%d\n", "Buz\n", "Fiz\n", "FizBuz\n" };
>   while ( x++ < 100 ) printf( Say[ 2*!(x%3) + !(x%5) ], x );
> 

And it hard-codes values, is limited to printf, and takes up as much
space as mine when you expand the array to 2^4, not to mention that
all your decision logic is entangled with the result function.

Mine is clean:

   void (*f[])(int)={zero,one,two,onetwo,
                     four,onefour,twofour,onetwofour,
                     eight,oneeight,twoeight,onetwoeight,
                     foureight,onefoureight,twofoureight,onetwofoureight};
   int i=0,v=0;
   for(i=1;i<=MAX;i++)
   {
      if(i%ONE==0){v+=1;}
      if(i%TWO==0){v+=2;}
      if(i%FOUR==0){v+=4;}
      if(i%EIGHT==0){v+=8;}
      f[v](i);  /* call the appropriate function */
      v=0;
   }

Flexible, easy to maintain, decision logic not entangled with
a single function so custom-tailored functions can be created
to handle different cases;  can easily be modified to set values
by parsing argv.  Think things through, man.  Look to the future.
Sometimes trying to be as concise as possible can tie your hands
and force you to end up doing a complete rewrite when you need
added functionality. 

[toc] | [prev] | [next] | [standalone]


#425988 — Re: I'm _still_ the best c coder here.

Frommoroney@world.std.spaamtrap.com (Michael Moroney)
Date2017-08-05 22:16 +0000
SubjectRe: I'm _still_ the best c coder here.
Message-ID<om5g3g$vb8$1@pcls7.std.com>
In reply to#425848
Jeff-Relf.Me  @. writes:

>Your shit was 28 lines, and very convolulted/confusing.

Your code is confusing/misleading by starting the counter at 0, not 1 even
if the first thing done is increment it.  For a half second I was about to
reply that you didn't even follow the requirements by starting at 0, not 1.

>  int x = 0 ; ...
>  while ( x++ < 100 ) printf( Say[ 2*!(x%3) + !(x%5) ], x );

Since the purpose of this code is to impress a potential employer, not
simply get the job done, it should be as clear and maintainable as
possible, and make it clearer that the loop iterates from 1 to 100.  
Besides, this type of iteration screams for a for(...) loop, that's why
languages were created with it or the equivalent. (I won't comment about
not making the requirement by misspelling 'Fizz' and 'Buzz'... :-) )

for (x=0; x<=100; x++) printf(...);

[toc] | [prev] | [next] | [standalone]


#426173 — Re: I increment things at the _start_ of a loop.

FromSteve Carroll <fretwizzer@gmail.com>
Date2017-08-06 11:04 -0700
SubjectRe: I increment things at the _start_ of a loop.
Message-ID<ac4591ea-3c48-4c8b-b570-0c1488d52c35@googlegroups.com>
In reply to#425988
On Saturday, August 5, 2017 at 10:42:13 PM UTC-6, Jeff-Relf.Me wrote:
> You ( Michael Moroney ) replied ( to me ):
> > >  int x = 0 ; while ( x++ < 100 ) printf(
> > 
> > for (x=0; x<=100; x++) printf(
> 
> No, it'd be:   for ( x = 1; x <= 100; x++ )

Some don't use ++, I believe Doug Crockford is against using it; instead
they opt for +=1 (or whatever value in place of 1).

[toc] | [prev] | [next] | [standalone]


#426336 — Re: I increment things at the _start_ of a loop.

Frommoroney@world.std.spaamtrap.com (Michael Moroney)
Date2017-08-07 03:24 +0000
SubjectRe: I increment things at the _start_ of a loop.
Message-ID<om8mhe$q18$3@pcls7.std.com>
In reply to#425988
Jeff-Relf.Me  @. writes:

>I increment things at the _start_ of a loop,
>not at the end, hence:  while ( x++ < 100 )

You missed my point, of course, being the idea of this exercise is to
convince a hiring manager that you write quality, clean, maintainable
code, not to try for the fewest possible lines or even the fastest code.
If I was the hiring manager, I'd take points off for unnecessary 
obscurity. (actually I wouldn't ask that question)

Like the Google interview question "how many ping pong balls fit into
a school bus?"  They don't give a flying fornification about an actual 
number, they want to see how the interviewee would estimate the answer.
They didn't ask me that when I interviewed with them, however.

[toc] | [prev] | [next] | [standalone]


#426339 — Re: I increment things at the _start_ of a loop.

FromSnit <usenet@gallopinginsanity.com>
Date2017-08-06 20:35 -0700
SubjectRe: I increment things at the _start_ of a loop.
Message-ID<D5AD2E0C.AF3F6%usenet@gallopinginsanity.com>
In reply to#426336
On 8/6/17, 8:24 PM, in article om8mhe$q18$3@pcls7.std.com, "Michael Moroney"
<moroney@world.std.spaamtrap.com> wrote:

> Jeff-Relf.Me  @. writes:
> 
>> I increment things at the _start_ of a loop,
>> not at the end, hence:  while ( x++ < 100 )
> 
> You missed my point, of course, being the idea of this exercise is to
> convince a hiring manager that you write quality, clean, maintainable
> code, not to try for the fewest possible lines or even the fastest code.
> If I was the hiring manager, I'd take points off for unnecessary
> obscurity. (actually I wouldn't ask that question)
> 
> Like the Google interview question "how many ping pong balls fit into
> a school bus?"  They don't give a flying fornification about an actual
> number, they want to see how the interviewee would estimate the answer.
> They didn't ask me that when I interviewed with them, however.

I had a similar question at a job interview (basically the same): how many
ping pong balls would fit into a 747.

-- 
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]


#426354 — Re: "while ( x++ < 100 )" isn't "obscure".

Frommoroney@world.std.spaamtrap.com (Michael Moroney)
Date2017-08-07 04:59 +0000
SubjectRe: "while ( x++ < 100 )" isn't "obscure".
Message-ID<om8s3n$40l$1@pcls7.std.com>
In reply to#426336
Jeff-Relf.Me  @. writes:

>> > I increment things at the _start_ of a loop,
>> > not at the end, hence:  while ( x++ < 100 )
>> 
>> If I was the hiring manager, 
>> I'd take points off for unnecessary obscurity.

>"while ( x++ < 100 )" isn't "obscure";
>people do stuff at the _start_ of a loop.

Starting off with "x = 0;" is obscure, or rather misleading. If you do
something for each integer from 1 to 100, you start at 1.  Like I said,
for a half a second I was about to mention you had a bug, the code
calculates FizzBuzz for 0, but that was misleading; you don't.  Looking
like you have a bug is almost as bad as having a bug, at least to the
hiring manager looking for someone who can write good, maintainable,
quality code.

[toc] | [prev] | [next] | [standalone]


#426387 — Re: I'm the best c coder here.

Fromchrisv <chrisv@nospam.invalid>
Date2017-08-07 06:59 -0500
SubjectRe: I'm the best c coder here.
Message-ID<aalgoch1e180r76m45q6u9foh32mbmfkbp@4ax.com>
In reply to#425848
owl wrote:

> Jeff-Relf.Me wrote:
>> 
>> Owl failed to write concise, readable code;
>
>Says the man who chose to use the least readable construct
>in the C language.

You're talking to a nut-job who thinks that "white space" is bad.  It
makes the code less compact, you see.

-- 
"(chrisv) claims (Relf's) code is shitty. Let's see him substantiate
it with some facts and a code analysis."  -  trolling fsckwit
"Ezekiel", regarding this mess:  http://jeff-relf.me/X.ZIP

[toc] | [prev] | [next] | [standalone]


#426872 — Re: I'm the best c coder here.

FromSteve Carroll <fretwizzer@gmail.com>
Date2017-08-08 10:23 -0700
SubjectRe: I'm the best c coder here.
Message-ID<6c28cf0f-bddb-46f7-bcb8-300f345daf47@googlegroups.com>
In reply to#426387
On Monday, August 7, 2017 at 5:59:49 AM UTC-6, chrisv wrote:
> owl wrote:
> 
> > Jeff-Relf.Me wrote:
> >> 
> >> Owl failed to write concise, readable code;
> >
> >Says the man who chose to use the least readable construct
> >in the C language.
> 
> You're talking to a nut-job who thinks that "white space" is bad.  It
> makes the code less compact, you see.


I've seen such posts by him but... in this very thread:

Message-ID: <Jeff-Relf.Me@Aug.2--5.46pm.Seattle.2017>

[toc] | [prev] | [next] | [standalone]


#425801 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

FromDFS <nospam@dfs.com>
Date2017-08-04 17:56 -0400
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<E46hB.138606$5A2.119409@fx28.iad>
In reply to#425770
On 8/4/2017 3:57 PM, fr314159@gmail.com wrote:
> 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.


Then why do you make the stupid-ass claim "REAL men write only in C"?

You're a self-contradicting moron, year after year after year.




> 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.


You can't program or code or develop (they're all the same thing, of 
course) worth a shit.  You wrongly believe a "programmer" executes at 
some nebulous level above a "coder".

You're full of shit.  Fuck you.

[toc] | [prev] | [next] | [standalone]


#425813 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

From"F. Russell" <fr@random.info>
Date2017-08-04 23:04 +0000
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<om2uhc0ceo@news4.newsguy.com>
In reply to#425801
On Fri, 04 Aug 2017 17:56:08 -0400, DFS wrote:

> 
> Then why do you make the stupid-ass claim "REAL men write only in C"?
> 

You are too stupid to understand that meaning depends on context.


> 
>  You wronglY believe a "programmer" executes at 
> some nebulous level above a "coder".
> 

That's why you will continue to apply outmoded 2D database searches.
You are just a code monkey that applies what other monkeys have done.

The true programmer, however, recognizes that z-order curves are
the most efficient approach, and furthermore, the true programmer
will quantify the efficiency without once considering how to implement
the process in code.

But you comprehend none of this.  I am wasting my breath on a brain-dead
monkey.

[toc] | [prev] | [next] | [standalone]


#425815 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

FromSnit <usenet@gallopinginsanity.com>
Date2017-08-04 16:09 -0700
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<D5AA4CCD.AEB9C%usenet@gallopinginsanity.com>
In reply to#425801
On 8/4/17, 2:56 PM, in article E46hB.138606$5A2.119409@fx28.iad, "DFS"
<nospam@dfs.com> wrote:

> On 8/4/2017 3:57 PM, fr314159@gmail.com wrote:
>> 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.
> 
> 
> Then why do you make the stupid-ass claim "REAL men write only in C"?

Nah, REAL men only use AppleScript! :)
 
> You're a self-contradicting moron, year after year after year.

I am sure someone will pull that quote out of context and pretend I really
meant it. 

>> 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.
> 
> 
> You can't program or code or develop (they're all the same thing, of
> course) worth a shit.  You wrongly believe a "programmer" executes at
> some nebulous level above a "coder".
> 
> You're full of shit.  Fuck you.
> 



-- 
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]


#425828 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

Fromfellatiohornblower@renlott.org
Date2017-08-04 20:13 -0400
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<om32bf$nle$1@dont-email.me>
In reply to#425815
On 08/04/2017 07:09 PM, Snit wrote:
> On 8/4/17, 2:56 PM, in article E46hB.138606$5A2.119409@fx28.iad, "DFS"
> <nospam@dfs.com> wrote:
> 
>> On 8/4/2017 3:57 PM, fr314159@gmail.com wrote:
>>> 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.
>>
>>
>> Then why do you make the stupid-ass claim "REAL men write only in C"?
> 
> Nah, REAL men only use AppleScript! :)

You are not a man, real or otherwise.
You are an effemanate, closet queen fag pretending to be a man.

It's quite obvious you know.

Proof is here.

https://www.youtube.com/watch?v=lvUomF8LLHo

And here:

http://prescottcomputerguy.com/assets/images/compguy1.jpg

FAGGOT !
And not the bundle of sticks kind.

[toc] | [prev] | [next] | [standalone]


#425917 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

From"F. Russell" <fr@random.info>
Date2017-08-05 13:50 +0000
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<om4ifa11hfk@news6.newsguy.com>
In reply to#425801
On Fri, 04 Aug 2017 17:56:08 -0400, DFS wrote:

> 
> You [rightly] believe a "programmer" executes at 
> some nebulous level above a "coder".
> 

That is correct, absolutely.

One of the first things they teach in the computer science
curriculum is how to WRITE A COMPILER.  Indeed, that's why
tools such at GNU Flex and Bison exist.  They allow the creation
of a unique language compiler.

The true programmer often invents his own language to suit
his own purposes.

That's because true programming is NOT about writing code.
The true programmer applies the principles of computer science
and even invents his own coding language to apply them.

There are PROGRAMMERS and there are CODERS.

Which one are you?

Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!

[toc] | [prev] | [next] | [standalone]


#425927 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

From"F. Russell" <fr@random.info>
Date2017-08-05 15:23 +0000
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<om4nth01kvn@news6.newsguy.com>
In reply to#425801
On Fri, 04 Aug 2017 17:56:08 -0400, DFS wrote:

> 
>> Coding is a SECONDARY activity that takes place AFTER the problem
>> has been analyzed and solved.
>> 

The Rosetta Code page for this problem proves my point completely.

On that page there are HUNDREDS of submitted code samples and,
without exception, they all use the DIVISION operation.

This is a BIG FAIL.  All those people are coders and not
programmers.

But a true analysis of the problem will reveal that, in this
case, the ADDITION operation is the best approach.

[toc] | [prev] | [next] | [standalone]


#425953 — Re: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.

FromSnit <usenet@gallopinginsanity.com>
Date2017-08-05 10:06 -0700
SubjectRe: Michael Glasser, Steve Carroll, Marek Novotny, Branimir Maksimovic, etc.
Message-ID<D5AB493C.AEEB9%usenet@gallopinginsanity.com>
In reply to#425927
On 8/5/17, 8:23 AM, in article om4nth01kvn@news6.newsguy.com, "F. Russell"
<fr@random.info> wrote:

> On Fri, 04 Aug 2017 17:56:08 -0400, DFS wrote:
> 
>> 
>>> Coding is a SECONDARY activity that takes place AFTER the problem
>>> has been analyzed and solved.
>>> 
> 
> The Rosetta Code page for this problem proves my point completely.

Just looked up the Rosetta Code AppleScript solution and see my solution is
almost exactly like what they have... which just means someone in COLA will
insist I looked up their solution first. :)

They do use "linefeed" and not "return" and use a property instead of a
variable for the list. Not sure of the value of either. They also, wisely I
think, have the "linefeed" separate from the other entries so you more
easily change it to a comma-delimited list or whatever.

Oh, and they use a string and not an array, which frankly makes a lot more
sense. No real value to my use of an array.

> On that page there are HUNDREDS of submitted code samples and,
> without exception, they all use the DIVISION operation.

No, they do not. The AppleScript one uses mod (as do others)
 
> This is a BIG FAIL.  All those people are coders and not
> programmers.
> 
> But a true analysis of the problem will reveal that, in this
> case, the ADDITION operation is the best approach.
> 


-- 
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]


Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →

Back to top | Article view | comp.os.linux.advocacy


csiph-web