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".
What do you mean, 90%? You need ten people for that. All I count are you, me, the sussman, and that faggot spamming ``hax my anus''.
1.upto(100) do |n|
tuna = n % 3 == 0
fish = n % 5 == 0
if tuna and fish
puts "FizzBuzz"
elsif tuna
puts "Fizz"
elsif fish
puts "Buzz"
else
puts n
end
end
Name:
Anonymous2008-04-25 12:53
import fizzbuzz
fizzbuzz f = new fizzbuzz(1,100)
print f.tostring()
Name:
Anonymous2008-04-25 13:00
mapM_ fizz [0..100]
where
fizz n | (mod n 3 == 0) && (mod n 5 ==0) = putStrLn (show n ++ " fizzbuzz")
| (mod n 3 == 0) = putStrLn (show n ++ " fizz")
| (mod n 5 == 0) = putStrLn (show n ++ " buzz")
| otherwise = putStrLn (show n)
I could've optimised it to three cases, but I am in hurry (by the way, fuck you OP, I will be late for a meeting because I had to prove you I can do it.).
Try changing the specifications to leverage the existing software assets.
Name:
The Ginger2008-04-25 14:08
i % (3*5) == 0 considered better than (i % 3 == 0) && (i % 5 == 0)
Name:
Anonymous2008-04-25 14:09
you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus'' you, me, the sussman, and that faggot spamming ``hax my anus''
>>19
I am from Uganda and I can assure you that I didn't.
Name:
Anonymous2008-04-25 14:24
fizzBuzz = mapM_ (putStrLn . check) [1..100] where
check n | n `mod` (3*5) == 0 = "FizzBuzz"
| n `mod` 3 == 0 = "Fizz"
| n `mod` 5 == 0 = "Buzz"
| otherwise = show n
Name:
Anonymous2008-04-25 14:30
>>20
Is your father the treasurer for the King? Do you need some cheques cashing?
Name:
Anonymous2008-04-25 14:35
>>11
NOT GOOD ENOUGH!
1. Make a loop from 1 to 100, and do all 100 checks in it ((i==1) and (ifcheck_div(1, 3, "Fizz") or check_div(1, 5, "Buzz")), or whatever that would be in your FIOC language)
2. MORE INDENTATION! if(i==1){
...
} else if(i==2){
...
} else if(i==3){
...
—bad idea!!! This is how you do it: if(i==1){
...
} else{
if(i==2){
...
} else{
if(i==3){
...
} else{
...
}
}
}
You have ways to go!
Oh, and your language sucks!!
Name:
Anonymous2008-04-25 14:53
>>23
There's a post length limit, you know. I had to make it shorter.
Name:
Anonymous2008-04-25 14:57
Apparently, my contributions to fourms was too large. This is an outrage. I'm never going to post code in comment again. Not only that—when I tried to post that to pastebin site, I got an error! "Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2759 bytes) in /home/pastebin/lib/geshi/geshi.php on line 1979". Does the world not want to see my creation?
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.mysticcoders.pastebin.model.PasteEntry#16103]
at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375)
at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:72)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)
at com.mysticcoders.pastebin.model.PasteEntry$$EnhancerByCGLIB$$c09a677.getName(<generated>)
at com.mysticcoders.pastebin.web.resource.ExportResource.setHeaders(ExportResource.java:27)
at org.apache.wicket.markup.html.WebResource.configureResponse(WebResource.java:52)
at org.apache.wicket.Resource.onResourceRequested(Resource.java:119)
at org.apache.wicket.request.target.resource.SharedResourceRequestTarget.respond(SharedResourceRequestTarget.java:190)
at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:103)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1100)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1169)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1245)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:489)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:354)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:173)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.ajp.Ajp13Connection.access$2700(Ajp13Connection.java:42)
at org.mortbay.jetty.ajp.Ajp13Connection$RequestHandler.headerComplete(Ajp13Connection.java:221)
at org.mortbay.jetty.ajp.Ajp13Parser.parseNext(Ajp13Parser.java:488)
at org.mortbay.jetty.ajp.Ajp13Parser.parseAvailable(Ajp13Parser.java:142)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
foreach(range(1,100) as $i) echo (($f=$i%3===0)?"Fizz":"").(($b=$i%5==0)?"Buzz":"").(($f|$b)==0?$i:"") . "\n";
Name:
Anonymous2008-04-25 16:21
1 to(100) each("x") {
case
{ x %(3) ==(0); } { writeLine("Fizz"); }
{ x %(5) ==(0); } { writeLine("Buzz"); }
{ x %(3 *(5)) ==(0); } { writeLine("FizzBuzz"); }
unless { writeLine(x); };
};
Here is my contribution, written in my own programming language, a derivative of Io (and indirectly, Smalltalk) that stole Ruby's syntax for blocks and also forgoes Io's syntactic sugar for infix expressions.
* Number#to constructs a range object.
* Range#each iterates over the range and accepts a single argument, the name to which the number in the range will be bound in the corresponding block.
* Object#case accepts mutually exclusive (predicate, action) block pairs and returns whether any of the predicates succeeded (making Bool#unless act as a sort of else clause).
Semicolon statement delimiters are needed (unfortunately) so that message send chains may be broken into several lines.
The interpreter, of course, is written in HASKELL.
Name:
Anonymous2008-04-25 16:27
>>32
ONE WORD: FORCED SEMI-COLONS IN THE CODE. THREAD OVER.
Name:
Anonymous2008-04-25 17:33
Some awesome trolling in this thread, from start to finish.
Here is my contribution, written in my own programming language, a derivative of Scheme (and indirectly, Lisp) that stole Ruby's syntax for symbols and also forgoes Scheme's tail recursion for loops.
* (iterate variable (from to) conditions) loops between 'from' and 'to' inclusive, and tests the conditions for each number.
* (number expression) prints the expression if the iteration variable is divisible by the number.
* (else expression) prints the expression if no previous number matched (making (iterate) act as a sort of switch statement).
Parentheses are needed (unfortunately) so that simultaneous iterators may retain their own lexical scope.
The interpreter, of course, is written in CROMA.
Name:
Anonymous2008-04-25 18:05
My attempt
Fizzbuz X where X is an integer
Int y = 0;
for (y = 0; y<300; Y+3)
if (x = y) then print Fizz
for (y = 0; y<30000; y+5}
if (y == x) then print buzz
esle print X
next line