Author Topic: =={challenge}== Programmer Test - Fizz/Buzz  (Read 7657 times)

0 Members and 1 Guest are viewing this topic.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #30 on: August 25, 2014, 06:33:01 AM »
IMHO,
from my tests is the best version is Stefan's:
Actually, it seems you're correct. I was hoping my IB:FizzBuzz1 would outperform it since it uses assoc instead of nth on the exact same algorithm. But from tests it seems to be about on par with each other (and as stated my IB:FizzBuzz3 is the exact same algorithm):
Code: [Select]
Benchmarking .................... done for 32768 iterations. Sorted from fastest.
Statement                                Increment  Time(ms) Normalize  Relative
--------------------------------------------------------------------------------
(MAPCAR (QUOTE IB:FIZZBUZZ3) FIZZLIST)       32768      1607      1607      1.00
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             32768      1654      1654      1.03
(MAPCAR (QUOTE IB:FIZZBUZZ1) FIZZLIST)       32768      1716      1716      1.07
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       32768      1919      1919      1.19
(MAPCAR (QUOTE PH:FB4) FIZZLIST)             32768      2012      2012      1.25
(MAPCAR (QUOTE PH:FB2) FIZZLIST)             32768      2043      2043      1.27
(MAPCAR (QUOTE IB:FIZZBUZZ) FIZZLIST)        16384      1030      2060      1.28
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1030      2060      1.28
(MAPCAR (QUOTE MAA:FIZZBUZZ_A2) FIZZ...)     16384      1045      2090      1.30
(MAPCAR (QUOTE LM:FIZZBUZZ) FIZZLIST)        16384      1185      2370      1.47
(MAPCAR (QUOTE MAA:FIZZBUZZ_A) FIZZL...)     16384      1202      2404      1.50
(MAPCAR (QUOTE IB:FIZZBUZZ2) FIZZLIST)       16384      1310      2620      1.63
(MAPCAR (QUOTE CAB:FIZZBUZZ) FIZZLIST)       16384      1326      2652      1.65
(JH:BIZZFIZZ FIZZLIST)                       16384      1341      2682      1.67
(MAPCAR (QUOTE KEITH:FB) FIZZLIST)           16384      1607      3214      2.00
(MAPCAR (QUOTE CHRISCARLSON:FIZZFUZZ...)     16384      1669      3338      2.08
(THARWAT:FIZZBUZZ FIZZLIST)                  16384      1966      3932      2.45
(MAPCAR (QUOTE RONJONP:_FB) FIZZLIST)         8192      1029      4116      2.56
(MAPCAR (QUOTE LM:FIZZBUZZ1) FIZZLIST)        8192      1576      6304      3.92
(MAPCAR (QUOTE IB:FIZZBUZZ4) FIZZLIST)        8192      6552     26208     16.31
--------------------------------------------------------------------------------
What does surprise me though is how much slower the member version is (even in comparison to the "naive" IB:FizzBuzz and IB:FizzBuzz0. And as I expected that convoluted IB:FizzBuzz4 of mine is rather silly-slow!

Great challenge Irné - although relatively simple, I've enjoyed this thread  :-)
My pleasure! It's a very simplistic challenge, but I thought it might be good since there are so many ways to achieve it.

:-o It's scary if you see that something this simple is failed by 99% of programming job candidates (i.e. they're UNABLE to write even the naive one)! It's even more scary when you consider most of those guys have at least some accreditation for being "programmers" behind their names - ouch for the "level" of their teaching if this is the case!
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1025
  • Marco
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #31 on: August 25, 2014, 08:43:46 AM »
as has been said many times it is not easy to test the speed,
better to exclude the slower  functions and do at least two tests:
Code: [Select]
Benchmarking .................... done for 32768 iterations. Sorted from fastest.
Statement                                Increment  Time(ms) Normalize  Relative
--------------------------------------------------------------------------------
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             32768      1904      1904      1.00
(MAPCAR (QUOTE IB:FIZZBUZZ1) FIZZLIST)       16384      1030      2060      1.08
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1107      2214      1.16
(MAPCAR (QUOTE IB:FIZZBUZZ1) FIZZLIST)       16384      1154      2308      1.21
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1186      2372      1.25
(MAPCAR (QUOTE IB:FIZZBUZZ) FIZZLIST)        16384      1232      2464      1.29
(MAPCAR (QUOTE PH:FB2) FIZZLIST)             16384      1232      2464      1.29
(MAPCAR (QUOTE PH:FB4) FIZZLIST)             16384      1248      2496      1.31
(MAPCAR (QUOTE LM:FIZZBUZZ) FIZZLIST)        16384      1373      2746      1.44
(MAPCAR (QUOTE PH:FB2) FIZZLIST)             16384      1514      3028      1.59
(MAPCAR (QUOTE LM:FIZZBUZZ) FIZZLIST)        16384      1544      3088      1.62
(MAPCAR (QUOTE MAA:FIZZBUZZ_A2) FIZZ...)     16384      1638      3276      1.72
(MAPCAR (QUOTE PH:FB4) FIZZLIST)             16384      1731      3462      1.82
(MAPCAR (QUOTE IB:FIZZBUZZ) FIZZLIST)        16384      1904      3808      2.00
(MAPCAR (QUOTE MAA:FIZZBUZZ_A2) FIZZ...)     16384      2028      4056      2.13
(MAPCAR (QUOTE PH:FB5) FIZZLIST)              8192      1077      4308      2.26
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)        8192      1124      4496      2.36
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)      8192      1154      4616      2.42
--------------------------------------------------------------------------------

Comando: (LOAD "E:/___DaSvuotare/FizzBuzz.LSP")
Benchmarking .................... done for 32768 iterations. Sorted from fastest.
Statement                                Increment  Time(ms) Normalize  Relative
--------------------------------------------------------------------------------
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             32768      1965      1965      1.06
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1170      2340      1.26
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1201      2402      1.29
(MAPCAR (QUOTE PH:FB4) FIZZLIST)             16384      1233      2466      1.33
(MAPCAR (QUOTE PH:FB2) FIZZLIST)             16384      1248      2496      1.34
(MAPCAR (QUOTE LM:FIZZBUZZ) FIZZLIST)        16384      1295      2590      1.39
(MAPCAR (QUOTE IB:FIZZBUZZ1) FIZZLIST)       32768      2621      2621      1.41
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             16384      1373      2746      1.48
(MAPCAR (QUOTE MAA:FIZZBUZZ_A2) FIZZ...)      8192      1030      4120      2.22
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)        8192      1046      4184      2.25
(MAPCAR (QUOTE MAA:FIZZBUZZ_A2) FIZZ...)     16384      2153      4306      2.32
(MAPCAR (QUOTE IB:FIZZBUZZ) FIZZLIST)        16384      2231      4462      2.40
(MAPCAR (QUOTE IB:FIZZBUZZ1) FIZZLIST)       16384      2434      4868      2.62
(MAPCAR (QUOTE PH:FB4) FIZZLIST)              8192      1372      5488      2.96
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)      8192      1373      5492      2.96
(MAPCAR (QUOTE IB:FIZZBUZZ) FIZZLIST)         8192      1513      6052      3.26
(MAPCAR (QUOTE PH:FB2) FIZZLIST)              8192      1513      6052      3.26
(MAPCAR (QUOTE LM:FIZZBUZZ) FIZZLIST)         8192      1560      6240      3.36
--------------------------------------------------------------------------------

Benchmarking ...... done for 32768 iterations. Sorted from fastest.
Statement                                Increment  Time(ms) Normalize  Relative
--------------------------------------------------------------------------------
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             32768      1903      1903      1.00
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1186      2372      1.25
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1201      2402      1.26
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1263      2526      1.33
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             16384      1607      3214      1.69
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1841      3682      1.93
--------------------------------------------------------------------------------

Benchmarking ...... done for 16384 iterations. Sorted from fastest.
Statement                                Increment  Time(ms) Normalize  Relative
--------------------------------------------------------------------------------
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1388      1388      1.00
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             16384      1435      1435      1.03
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             16384      1529      1529      1.10
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1591      1591      1.15
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1716      1716      1.24
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)      8192      1060      2120      1.53
--------------------------------------------------------------------------------

Benchmarking ...... done for 32768 iterations. Sorted from fastest.
Statement                                Increment  Time(ms) Normalize  Relative
--------------------------------------------------------------------------------
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             32768      2013      2013      1.00
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)       16384      1108      2216      1.10
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)     16384      1186      2372      1.18
(MAPCAR (QUOTE PH:FB5) FIZZLIST)             16384      1762      3524      1.75
(MAPCAR (QUOTE KERRY:FIZZBUZZ) FIZZL...)      8192      1326      5304      2.63
(MAPCAR (QUOTE IB:FIZZBUZZ0) FIZZLIST)        8192      1373      5492      2.73
--------------------------------------------------------------------------------

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #32 on: August 25, 2014, 08:55:11 AM »
True! Benchmarking's not exactly a perfect idea anyway.

Anyhow, this C# version should probably do much faster as it uses the compiler's built-in hashmap for the switch statement: http://ideone.com/EDf0iZ

And of course the C version of the same is rather verbose in the extreme! http://ideone.com/5A7uUd

Just got a hell of a shock! Read the comments here: http://raganwald.com/2007/01/dont-overthink-fizzbuzz.html

Then go and try them out on http://ideone.com

Just look at how many of those guys give code which simply doesn't work!
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #33 on: August 25, 2014, 09:17:09 AM »
irne,

Why no negative or real numbers in the test list ?
That's because you then tend to get into a bit more "advanced" ideas which differ between languages, operators and functions. And that's not what the test is about, it's more about can you think about the logic of what needs to happen instead of the nuances for any detail involved.

E.g. you could obtain inaccurate results depending on the type of float the program uses - floating point division is rather inconsistent especially when using equality comparisons. Negatives are also a bit weird as some languages implement the modulo operator in a different way than others when it comes to negative numbers. Thus by enforcing only positive integers the test is much simplified and more consistent for any language, system, environment, etc.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12313
  • London, England
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #34 on: August 25, 2014, 09:30:33 AM »
FWIW, ph:FB5 could be made marginally more concise as the last two nils aren't required:
Code - Auto/Visual Lisp: [Select]
  1. (defun ph:FB5 ( n )
  2.     (cond ((nth (rem n 15) '("FizzBuzz" nil nil "Fizz" nil "Buzz" "Fizz" nil nil "Fizz" "Buzz" nil "Fizz"))) (n))
  3. )

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1025
  • Marco
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #35 on: August 25, 2014, 09:37:07 AM »
True, how many things are not seen at first glance!
Thanks Lee.  8)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #36 on: August 25, 2014, 11:36:24 AM »
my variant:
Code - Auto/Visual Lisp: [Select]
  1. (defun eea (l)
  2.   (if l
  3.     (append (mapcar (function (lambda (a b)
  4.                                 (cond (a)
  5.                                       (b)
  6.                                 )
  7.                               )
  8.                     )
  9.                     '(nil nil "Fizz" nil "Buzz" "Fizz" nil nil "Fizz" "Buzz" nil "Fizz" nil nil "FizzBuzz")
  10.                     l
  11.             )
  12.             (eea (cddddr (cddddr (cddddr (cdddr l)))))
  13.     )
  14.   )
  15. )
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

Lee Mac

  • Seagull
  • Posts: 12313
  • London, England
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #37 on: August 25, 2014, 12:21:15 PM »
Oustanding as always Evgeniy  :coolsmiley:

Code - Auto/Visual Lisp: [Select]
  1. _$ l
  2. (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
  3. _$ (benchmark '((eea l) (mapcar 'ph:fb5 l)))
  4. Benchmarking .................Elapsed milliseconds / relative speed for 16384 iteration(s):
  5.  
  6.     (EEA L).......................1014 / 1.26 <fastest>
  7.     (MAPCAR (QUOTE PH:FB5) L).....1279 / 1.00 <slowest>

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #38 on: August 25, 2014, 01:22:53 PM »
Thank you!
But my code is adapted to the current sort lists. :-(
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

Lee Mac

  • Seagull
  • Posts: 12313
  • London, England
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #39 on: August 25, 2014, 01:41:27 PM »
Thank you!
But my code is adapted to the current sort lists. :-(

Nevertheless, it meets the criteria set by the challenge  :-P

Stefan

  • Bull Frog
  • Posts: 221
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #40 on: August 25, 2014, 03:29:07 PM »
Nevertheless, it meets the criteria set by the challenge  :-P
eea takes a list as an argument; all others (with a few exceptions) takes an integer, as in OP. So you have comparing two different things.
Even so, try it on a larger list (say 1 ... 1000).


ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #41 on: August 27, 2014, 04:55:53 AM »
my new version for a large list:

Code - Auto/Visual Lisp: [Select]
  1. (defun eea1 (l / a)
  2.   ;; for a large list
  3.   (while l
  4.     (setq a (cons (mapcar (function (lambda (a b)
  5.                                       (cond (a)
  6.                                             (b)
  7.                                       )
  8.                                     )
  9.                           )
  10.                           '(nil nil      "Fizz"   nil      "Buzz"   "Fizz"   nil      nil      "Fizz"   "Buzz"
  11.                                 nil      "Fizz"   nil      nil      "FizzBuzz"        nil      nil      "Fizz"
  12.                                 nil      "Buzz"   "Fizz"   nil      nil      "Fizz"   "Buzz"   nil      "Fizz"
  13.                                 nil      nil      "FizzBuzz"
  14.                                )
  15.                           l
  16.                   )
  17.                   a
  18.             )
  19.           l (cddr (cddddr (cddddr (cddddr
  20.                                       (cddddr (cddddr (cddddr (cddddr l))))))))
  21.     )
  22.   )
  23. )

test:
Code - Auto/Visual Lisp: [Select]
  1. (defun eea (l)
  2.   ;; for a small list
  3.   (if l
  4.     (append (mapcar (function (lambda (a b)
  5.                                 (cond (a)
  6.                                       (b)
  7.                                 )
  8.                               )
  9.                     )
  10.                     '(nil nil "Fizz" nil "Buzz" "Fizz" nil nil "Fizz" "Buzz" nil "Fizz" nil nil "FizzBuzz")
  11.                     l
  12.             )
  13.             (eea (cddddr (cddddr (cddddr (cdddr l)))))
  14.     )
  15.   )
  16. )
  17. (defun eea1 (l / a)
  18.   ;; for a large list
  19.   (while l
  20.     (setq a (cons (mapcar (function (lambda (a b)
  21.                                       (cond (a)
  22.                                             (b)
  23.                                       )
  24.                                     )
  25.                           )
  26.                           '(nil nil      "Fizz"   nil      "Buzz"   "Fizz"   nil      nil      "Fizz"   "Buzz"
  27.                                 nil      "Fizz"   nil      nil      "FizzBuzz"        nil      nil      "Fizz"
  28.                                 nil      "Buzz"   "Fizz"   nil      nil      "Fizz"   "Buzz"   nil      "Fizz"
  29.                                 nil      nil      "FizzBuzz"
  30.                                )
  31.                           l
  32.                   )
  33.                   a
  34.             )
  35.           l (cddr (cddddr (cddddr (cddddr
  36.                                       (cddddr (cddddr (cddddr (cddddr l))))))))
  37.     )
  38.   )
  39. )
  40. (defun ph:FB5 (n)
  41.   (cond ((nth (rem n 15)
  42.               '("FizzBuzz" nil nil "Fizz" nil "Buzz" "Fizz" nil nil "Fizz" "Buzz" nil "Fizz" nil nil)
  43.          )
  44.         )
  45.         (n)
  46.   )
  47. )
  48. (defun c:test (/ l)
  49.   (foreach i '(30 300 3000)
  50.     (princ (strcat "\n\nList length " (itoa i) "\n"))
  51.     (setq l nil)
  52.     (repeat i
  53.       (setq l (cons i l)
  54.             i (1- i)
  55.       )
  56.     )
  57.     (benchmark '((mapcar (function ph:fb5) l) (eea l) (eea1 l)))
  58.   )
  59.   (princ)
  60. )

result:
Code: [Select]
List length 30
Elapsed milliseconds / relative speed for 65536 iteration(s):

    (EEA1 L).........................1997 / 1.23 <fastest>
    (EEA L)..........................2106 / 1.16
    (MAPCAR (FUNCTION PH:FB5) L).....2449 / 1 <slowest>


List length 300
Elapsed milliseconds / relative speed for 8192 iteration(s):

    (EEA1 L).........................1451 / 2.57 <fastest>
    (MAPCAR (FUNCTION PH:FB5) L).....1840 / 2.03
    (EEA L)..........................3729 / 1 <slowest>


List length 3000
Elapsed milliseconds / relative speed for 1024 iteration(s):

    (EEA1 L)..........................1607 / 14.35 <fastest>
    (MAPCAR (FUNCTION PH:FB5) L)......2075 / 11.11
    (EEA L)..........................23057 / 1 <slowest>
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #42 on: August 27, 2014, 06:03:21 AM »
whole the test:
Code: [Select]
Command: TEST

List length 30
Elapsed milliseconds / relative speed for 32768 iteration(s):

    (EEA1 L).....................................1108 / 7.62 <fastest>
    (EEA L)......................................1154 / 7.31
    (MAPCAR (QUOTE PH:FB5) L)....................1279 / 6.6
    (MAPCAR (QUOTE IB:FIZZBUZZ3) L)..............1310 / 6.44
    (MAPCAR (QUOTE MAA:FIZZBUZZ_A2) L)...........1684 / 5.01
    (MAPCAR (QUOTE PH:FB2) L)....................1825 / 4.62
    (MAPCAR (QUOTE PH:FB4) L)....................1841 / 4.58
    (MAPCAR (QUOTE KERRY:FIZZBUZZ) L)............1904 / 4.43
    (MAPCAR (QUOTE MAA:FIZZBUZZ_A) L)............1981 / 4.26
    (MAPCAR (QUOTE LM:FIZZBUZZ) L)...............2043 / 4.13
    (MAPCAR (QUOTE IB:FIZZBUZZ2) L)..............2137 / 3.95
    (MAPCAR (QUOTE CAB:FIZZBUZZ) L)..............2372 / 3.56
    (MAPCAR (QUOTE IB:FIZZBUZZ1) L)..............2606 / 3.24
    (MAPCAR (QUOTE IB:FIZZBUZZ0) L)..............2714 / 3.11
    (JH:BIZZFIZZ L)..............................2808 / 3.01
    (MAPCAR (QUOTE IB:FIZZBUZZ) L)...............2917 / 2.89
    (MAPCAR (QUOTE CHRISCARLSON:FIZZFUZZ...).....3073 / 2.75
    (MAPCAR (QUOTE KEITH:FB) L)..................3307 / 2.55
    (THARWAT:FIZZBUZZ L).........................3588 / 2.35
    (MAPCAR (QUOTE RONJONP:_FB) L)...............3744 / 2.25
    (MAPCAR (QUOTE LM:FIZZBUZZ1) L)..............6162 / 1.37
    (MAPCAR (QUOTE IB:FIZZBUZZ4) L)..............8440 / 1 <slowest>


List length 300
Elapsed milliseconds / relative speed for 8192 iteration(s):

    (EEA1 L)......................................1560 / 12.68 <fastest>
    (MAPCAR (QUOTE PH:FB5) L).....................1887 / 10.48
    (MAPCAR (QUOTE IB:FIZZBUZZ3) L)...............1903 / 10.39
    (MAPCAR (QUOTE IB:FIZZBUZZ1) L)...............2324 / 8.51
    (MAPCAR (QUOTE IB:FIZZBUZZ0) L)...............2808 / 7.04
    (MAPCAR (QUOTE MAA:FIZZBUZZ_A2) L)............2964 / 6.67
    (MAPCAR (QUOTE IB:FIZZBUZZ) L)................3245 / 6.1
    (MAPCAR (QUOTE PH:FB2) L).....................3260 / 6.07
    (MAPCAR (QUOTE PH:FB4) L).....................3323 / 5.95
    (MAPCAR (QUOTE KERRY:FIZZBUZZ) L).............3323 / 5.95
    (MAPCAR (QUOTE MAA:FIZZBUZZ_A) L).............3635 / 5.44
    (MAPCAR (QUOTE LM:FIZZBUZZ) L)................3775 / 5.24
    (MAPCAR (QUOTE IB:FIZZBUZZ2) L)...............3931 / 5.03
    (EEA L).......................................3978 / 4.97
    (JH:BIZZFIZZ L)...............................4540 / 4.36
    (MAPCAR (QUOTE CAB:FIZZBUZZ) L)...............4587 / 4.31
    (MAPCAR (QUOTE CHRISCARLSON:FIZZFUZZ...)......6349 / 3.12
    (THARWAT:FIZZBUZZ L)..........................6817 / 2.9
    (MAPCAR (QUOTE KEITH:FB) L)...................6942 / 2.85
    (MAPCAR (QUOTE RONJONP:_FB) L)................7972 / 2.48
    (MAPCAR (QUOTE LM:FIZZBUZZ1) L)..............15663 / 1.26
    (MAPCAR (QUOTE IB:FIZZBUZZ4) L)..............19781 / 1 <slowest>


List length 3000
Elapsed milliseconds / relative speed for 1024 iteration(s):

    (EEA1 L)......................................1701 / 14.19 <fastest>
    (MAPCAR (QUOTE IB:FIZZBUZZ3) L)...............2121 / 11.38
    (MAPCAR (QUOTE PH:FB5) L).....................2137 / 11.29
    (MAPCAR (QUOTE IB:FIZZBUZZ1) L)...............2668 / 9.05
    (MAPCAR (QUOTE IB:FIZZBUZZ0) L)...............3276 / 7.37
    (MAPCAR (QUOTE MAA:FIZZBUZZ_A2) L)............3432 / 7.03
    (MAPCAR (QUOTE PH:FB2) L).....................3853 / 6.26
    (MAPCAR (QUOTE IB:FIZZBUZZ) L)................3854 / 6.26
    (MAPCAR (QUOTE KERRY:FIZZBUZZ) L).............3915 / 6.16
    (MAPCAR (QUOTE PH:FB4) L).....................3916 / 6.16
    (MAPCAR (QUOTE MAA:FIZZBUZZ_A) L).............4353 / 5.54
    (MAPCAR (QUOTE LM:FIZZBUZZ) L)................4446 / 5.43
    (MAPCAR (QUOTE IB:FIZZBUZZ2) L)...............4649 / 5.19
    (MAPCAR (QUOTE CAB:FIZZBUZZ) L)...............5491 / 4.4
    (JH:BIZZFIZZ L)...............................5522 / 4.37
    (MAPCAR (QUOTE CHRISCARLSON:FIZZFUZZ...)......7800 / 3.09
    (MAPCAR (QUOTE KEITH:FB) L)...................7862 / 3.07
    (THARWAT:FIZZBUZZ L)..........................8362 / 2.89
    (MAPCAR (QUOTE RONJONP:_FB) L)................9719 / 2.48
    (MAPCAR (QUOTE LM:FIZZBUZZ1) L)..............18845 / 1.28
    (MAPCAR (QUOTE IB:FIZZBUZZ4) L)..............24071 / 1
    (EEA L)......................................24134 / 1 <slowest>
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #43 on: August 27, 2014, 07:01:42 AM »
test code  :-)
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: =={challenge}== Programmer Test - Fizz/Buzz
« Reply #44 on: August 27, 2014, 07:35:33 AM »
Evgeniy,

The specification was to pass a number, not a list.

and I think your routine will fail if the list is anything other than a sequential list of numbers starting at 1.

... the function should return the correct results if called as :

Code - Auto/Visual Lisp: [Select]
  1. (mapcar 'FizzBuzz '(3 2 1 300 1500 120 42 50)
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--