The Warwick Mathematics Society Website

User login

Upcoming events

  • No upcoming events available

There are 394 members of the Warwick Mathematics Society, of which 14 are new today!
We're 78% of the way toward our target of 500 members.
You can join up on the UWSU website.

Fizz Buzz

Post Icon Posted: Submitted by Smithers on 19 May 2008 - 5:41pm.

Joined: 2006-10-18
Posts: 29

Fizz buzz from 1 to 100:
With penhalagen for 9s and switching fizz and buzz.
As described by Tom at Top. B, suggested by Alex about 10 minutes ago, and implemented by me now.

1
2
3
4
fizz
6
buzz
8
penhalagen
buzz
11
12
13
fizz
buzz
16
fizz
penhalagen
penhalagen
buzz
fizz
22
23
24
buzz
26
fizzpenhalagen
buzz
penhalagen
buzz
31
32
33
34
buzzfizz
penhalagen
buzz
38
penhalagen
buzz
41
fizz
43
44
buzzpenhalagen
46
buzz
48
buzzpenhalagen
buzz
buzz
buzz
buzz
buzzpenhalagen
fizz
fizzbuzz
fizzbuzz
fizz
fizzpenhalagen
buzz
61
62
fizzpenhalagen
64
fizz
66
buzz
68
penhalagen
buzzfizz
fizz
fizzpenhalagen
buzz
buzz
fizzbuzz
buzz
buzz
buzz
buzzpenhalagen
buzz
penhalagen
82
83
buzz
fizz
86
buzz
88
penhalagen
buzzpenhalagen
buzzpenhalagen
penhalagen
penhalagen
penhalagen
fizzpenhalagen
penhalagen
buzzpenhalagen
fizzpenhalagen
penhalagen
buzz

Java Code:
public class FizzBuzz { public static void main(String[] args) { String output="", iStr=""; String fizz="fizz", buzz="buzz", temp=""; for(int i=1; i<=100; i++) { output=""; iStr=Integer.toString(i); if((i%5==0) || iStr.matches("\\d*5\\d*")) output+=fizz; if((i%7==0) || iStr.matches("\\d*7\\d*")) output+=buzz; if((i%9==0) || iStr.matches("\\d*9\\d*")) { output+="penhalagen"; temp=fizz; fizz=buzz; buzz=temp; } if(output.equals("")) output=iStr; System.out.println(output); } } }

Post Icon Posted: 19 May 2008 - 5:47pm

Joined: 2006-11-02
Posts: 1090

You mean from 1 to fizz (or buzz according to the switching thing). :p

Post Icon Posted: 19 May 2008 - 6:08pm

Joined: 2006-10-05
Posts: 699

Consume for lameness!

Post Icon Posted: 19 May 2008 - 6:11pm

Joined: 2006-11-02
Posts: 1090

"What's another word for consume?"

Post Icon Posted: 19 May 2008 - 6:12pm

Joined: 2006-10-05
Posts: 699

???

Why the quoting.

Post Icon Posted: 19 May 2008 - 6:15pm

Joined: 2006-11-02
Posts: 1090

It starts with P and finishes with G.

Post Icon Posted: 19 May 2008 - 6:17pm

Joined: 2006-10-05
Posts: 699

ping pong, i got it.

Post Icon Posted: 20 May 2008 - 12:40am

Joined: 2006-11-02
Posts: 1090

The answer was Pig.

Post Icon Posted: 20 May 2008 - 12:54am

Joined: 2006-10-05
Posts: 699

I was very close at least.

Post Icon Posted: 23 May 2008 - 1:02am

Joined: 2006-10-18
Posts: 29

Stop hijacking threads just to abuse each other

Post Icon Posted: 23 May 2008 - 1:31am

Joined: 2006-11-02
Posts: 1090

I hardly abused him though. :p

Post Icon Posted: 23 May 2008 - 10:47am

Joined: 2006-10-05
Posts: 699

That's what Hat McCullough said.

Post Icon Posted: 26 May 2008 - 8:33am

Joined: 2007-10-01
Posts: 179

the funniest thing of all, is that you guys live in the same house but still manage to argue on the forums.

Post Icon Posted: 26 May 2008 - 8:38am

Joined: 2007-10-17
Posts: 109

I kept meaning to point that out.

Post Icon Posted: 26 May 2008 - 3:01pm

Joined: 2006-10-05
Posts: 699

It keeps the noise down.

Post Icon Posted: 26 May 2008 - 3:46pm

Joined: 2006-11-02
Posts: 1090

Well that's half the reason I do it. I keep walking past him in the middle of some of the flame wars and we usually just laugh about it. :P