what is your fave PoSh version of FizzBuzz?

howdy y’all,

saw the “why fizzbuzz” post over in r/programming the other day. it reminded me of several conversations on why to use it. the thread over there was a nice discussion of the whys and why-nots.

the thing that stuck in my head was the vast number of ways that folks solved the problem. fun to read! [grin]

so, what is your fave PoSh version? here’s mine …

$WN_List = @' Word, Number Fizz, 3 Buzz, 5 Kwizz, 7 '@ | ConvertFrom-Csv $StartNum = 1 $EndNum = 110 $Range = $StartNum..$EndNum foreach ($R_Item in $Range) { $Output = '' foreach ($W_Item in $WN_List) { $Output += ('', $W_Item.Word)[$R_Item % $W_Item.Number -eq 0] } if ($Output -eq '') { $Output = $R_Item } $Output } 

results [snipped rather a lot] …

97 Kwizz Fizz Buzz 101 Fizz 103 104 FizzBuzzKwizz 106 107 Fizz 109 Buzz 

had to run it to at least 105 since that is the 1st crossing of 3,5,7.

take care,
lee

submitted by /u/Lee_Dailey
[link] [comments]

Leave a Reply