From: demon.adramelek@nospicedham.gmail.com   
      
   On Thursday, July 19, 2018 at 6:11:00 AM UTC-5, Bernhard Schornak wrote:   
   > fizz buzz wrote:   
   >   
   >   
   >    
   >   
   >   
   > Theoretical thought:   
   >   
   > The inserted FIZZes, BUZZes and FIZZBUZZes always follow the   
   > same pattern   
   >   
   > n1   
   > n2   
   > FIZZ   
   > n4   
   > BUZZ   
   > FIZZ   
   > n7   
   > n8   
   > FIZZ   
   > BUZZ   
   > n11   
   > FIZZ   
   > n13   
   > n14   
   > FIZZBUZZ   
   >   
   >   
   > Hence, we can save all comparisons regarding replacement and   
   > prefill the output buffer with the above pattern as often as   
   > required to reach the desired number. If we define a *fixed*   
   > output size (e.g.: 8 byte for 6 digit numbers plus line feed   
   > plus trailing zero), the above patterns could be loaded into   
   > eight XMM registers and moved to the output buffer n/8 times   
   > to "bypass" the comparisons completely.   
      
   This is a good thought. However, a *fixed* output size might be considered   
   cheating, since all other FizzBuzz programs have to deal with non-fixed   
   strings.   
      
   If it were possible to do fixed-size strings, I probably would try to write   
   threaded version. One thread for Fizzes, one for Buzzes, one for FizzBuzzes,   
   and one for numbers. However, that would only work in case of fixed-size   
   strings, because it would be possible to calculate string offsets without   
   caring   
   about lengths of other strings.   
      
   Here is another cheating thought. Original rules say:   
      
   > Write a program that prints the numbers from 1 to 100...   
      
   But it does not say that they have to be printed in sequence! "From 1 to   
   100" is just a range, so theoretically output can be in any sequence or even   
   out of sequence. This makes threaded version possible. Again, one thread for   
   Fizzes, one for Buzzes, one for FizzBuzzes, and one for numbers. The only   
   problem Is that output will not be synchronized... but should it? :-)   
      
   > If we use another fixed pattern for the numbers to print, we   
   > can skip the hex to dec translation, as well, and replace it   
   > by brute force incrementing zeroes until we reach the nines.   
   > Then we just had to increment the next higher digits and re-   
   > set the lowest one by zero to repeat until the entire number   
   > is processed.   
   >   
   >   
   > Just my five cents...   
   >   
   >   
   > Bernhard Schornak   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|