Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
Name:
Anonymous2008-04-27 16:59
>>119,120
This is actually and enjoyable thread. You guys are too grumpy.
Name:
Anonymous2008-04-27 16:59
>>120
It's incredible how much fail can accumulate in just one *chan
>>118
It's not so much an encouraged Python practice as something people carry over from Perl.
>>121
Not really. Everything in the thread is either trivial or lifted from somewhere else.
Name:
Anonymous2008-04-27 23:28
>>124
I didn't say it is instructive, I said it is enjoyable. Also, what do you care if posts were lifted from somewhere else? Everyone is anonymous anyway, it doesn't matter.
<@MrVacBob> i should add reporting i guess
<@MrVacBob> dis moderators are.... some people, i guess, but i'm the only one who would read prog and i don't understand it at all
interface IFizzBuzz
{
public function setFizzBuzz($fizz = null, $buzz = null);
public function checkFizz($int);
public function checkBuzz($int);
public function generateFizzBuzz();
}
class FizzBuzz implements IFizzBuzz
{
/**
* Fizz
*
* @var string
*/
public $fizzText = 'Fizz';
/**
* Buzz
*
* @var string
*/
public $buzzText = 'Buzz';
/**
* Lower interger range.
*
* @var int
*/
public $lowerInt = 1;
/**
* Upper interger range.
*
* @var int
*/
public $upperInt = 100;
return ($int % 3 == 0) ? true : false;
i would like you to write a formal explanation of the ternary operator and tell me why that statement is so redundant
Name:
Anonymous2008-04-28 6:21
>>128
too lazy, otherwise i would have added more garbage to my code
i'm not really sure why i added the ternary operator in there
but you can keep it as a momento of my shitty code
>>145 Click photo to enlarge http://www.fluffycat.com/photograph--1/ Fatal error: Call to undefined function: numberofphotosfortopicname() in /home/fluff4/public_html/core/photo_functions.php on line 176
I lold.
Name:
Anonymous2008-04-29 13:47
// C
include <stdio.h>
int main() {
printf("lol");
return 69;
}
Name:
Anonymous2008-04-29 14:04
return 69;
wuts it do?
Name:
Anonymous2008-04-29 16:49
import Control.Monad.Instances
import Function
import Monad
>>153 Functional programming considered harmful Guido Van rossum
Name:
Anonymous2008-04-29 21:24
Bow down before the ENTERPRISE package fizzbuzz;
public interface IFizzBuzz {
public void setStart();
public void setEnd();
public String getFizzBuzz();
}
=================================================
package fizzbuzz;
/**
* Singleton adapter factory
*/
public class FizzBuzzFactory {
public static final FizzBuzzFactory INSTANCE = new FizzBuzzFactory();
private FizzBuzzFactory() {
registerAdapters();
}
public <T> createInstance(Class<T> clazz) {
if (clazz == IFizzBuzz.class) {
return new FizzBuzzImpl();
} else return null;
}
public String getFizzBuzz() {
String result = "";
for (int i = fStart; i <= fEnd; i++) {
if (getFizz(i) && getBuzz(i))
result += "FizzBuzz";
else if (getFizz(i))
result += "Fizz";
else if (getBuzz(i))
result += "Buzz";
else result += i;
}
return result;
}
}
=================================================
import junit.framework.*;
public class TestFizzBuzz extends TestCase {
public void setUp() {
}
public void tearDown() {
}
public void testGetFizzBuzz() {
IFizzBuzz f = FizzBuzzFactory.INSTANCE.createInstance(IFizzBuzz.class);
f.setStart(1);
f.setEnd(100);
AssertEquals(f.getFizzBuzz(),