Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I Propose a challenge. (FIZZ BUZZ)

Name: Anonymous 2007-09-01 20:19 ID:Ei0Nz+V2

The fizz buzz challenge

Make a program(in the language of your choice), that goes like this:

1)Prints all numbers from one to one hundred
2)For every number that can be divided with 3, it writes "fizz" next to the number.
3)For every number that can be divided with 5, it writes "buzz".

Should look like this:

1
2
3 Buzz
4
5 Fizz
6 Buzz
7
8
9 Buzz
10 Fizz
11
12 Buzz
13
14
15 FizzBuzz
16
17
18 Buzz

This a common problem employers give to seperate the Expert programers from the Enterprise Qulity Programmers. Surprisingly, not many programmers can. I made one in BASIC in 5 minutes.

Lets see how /PROG/ stands up to this.

Name: Anonymous 2007-09-03 23:05 ID:fCY+jKkf

>>120
>>1 is included in "you all".

Name: Anonymous 2007-09-03 23:18 ID:Heaven

someone needs to make a language where you can do this:
fizzbuzz ( int x ) = x
fizzbuzz ( * 3 int x ) = 'Fizz'
fizzbuzz ( * 5 int x ) = 'Buzz'
fizzbuzz ( * 15 int x ) = 'FizzBuzz'
main = print fizzbuzz range ( 1 100 )

Name: Anonymous 2007-09-04 1:05 ID:Heaven

someone needs to make a language where 'fizzbuzz' is a built-in construct which outputs the expected output of a fizzbuzz program.

Name: Anonymous 2007-09-04 2:22 ID:xie+ODtL

Name: Anonymous 2007-09-04 2:22 ID:3nCcnzW0

well you guys are all retarded but at least some of you are using haskell

Name: Anonymous 2007-09-04 2:45 ID:LZwk4Mjk

>>116
see >>74.

Name: Anonymous 2007-09-04 2:49 ID:xie+ODtL

>>122
It exists.  Erlang, bitches!  Tested code for your example, not the initial problem:

-module(fizzbuzz).
-export([fizzbuzz/0]).

output(N) when (N rem 15) == 0 -> "FizzBuzz";
output(N) when (N rem 3) == 0 -> "Fizz";
output(N) when (N rem 5) == 0 -> "Buzz";
output(N) -> N.

fizzbuzz() -> lists:map(fun output/1, lists:seq(1,100)).


Returns:

[1,
 2,
 "Fizz",
 4,
 "Buzz",
 "Fizz",
 7,
 8,
 "Fizz",
 "Buzz",
 11,
 "Fizz",
 13,
 14,
 "FizzBuzz",
 16,
 17,
 "Fizz",
 19,
 "Buzz",
 "Fizz",
 22,
 23,
 "Fizz",
 "Buzz",
 26,
 "Fizz",
 28,
 29|...]

Name: Anonymous 2007-09-04 3:27 ID:8yD3jPJZ

>>127
As if Erlang was unique in this respect. Haskell:

divides y x = x `mod` y == 0

fizzbuzz n | 15 `divides` n = "FizzBuzz"
fizzbuzz n | 3  `divides` n = "Fizz"
fizzbuzz n | 5  `divides` n = "Buzz"
fizzbuzz n = show n

fizzer = map fizzbuzz [1 .. 100]

Name: Anonymous 2007-09-04 3:55 ID:OmkNvkoD

Javascript:
for(i=1;i<=100;i++){
    document.write(i);
    if(i%3==0) document.write("fizz");
    if(i%5==0) document.write("buzz");
    document.write("<br />");
}

Name: Anonymous 2007-09-04 4:36 ID:0tw/xZSU

>>127-128
read >>122 again and come back when you can do this:
uncrypt ( crypt s ) = s

Name: Anonymous 2007-09-04 4:54 ID:yIXX+FTo

>>107
respect

Name: Anonymous 2007-09-04 4:56 ID:8yD3jPJZ

>>130
crypt = rot13
uncrypt = rot13


Done. Still waiting for the erlangfag.

Name: Anonymous 2007-09-04 5:18 ID:Jfr8kznv

>>107
Enterprise

Name: Anonymous 2007-09-04 5:19 ID:Heaven

>>132
rot13 = crypt
rot13 = uncrypt


Nonono.

Name: Anonymous 2007-09-04 6:42 ID:L6ZyapEI

New challange.
Write a simple shell interpreter using fork/exec. It should be able to support simple pipelining and redirection.
Is /prog/ up for the challenge?

Name: Anonymous 2007-09-04 6:52 ID:uUaK9Pge

>>135
More specification please

Name: Anonymous 2007-09-04 7:20 ID:Jfr8kznv

>>135
int main() {
    return system("sh");
}


I'm not doing your homework.

Name: Anonymous 2007-09-04 7:22 ID:L6ZyapEI

>>136
The shell interpreter is to be a little simplistic, all you can do is execute commands, pipe output to other programs as well as redirect input/output. To implement command execution you should use the function call fork() and exec(). Note that there are many variations on the exec() function call. To block the shell, you
should use the wait() (or similar) function call.
You should use dup2 and pipe to redirect stdin and stdout.
Your interpreter should be able to do the following
$ ./foobar
./foobar does not exist.
$ ls –la > out.txt
$ ls -la | wc > foo

Name: Anonymous 2007-09-04 8:00 ID:Heaven

Take your homework and GTFO.

Name: Anonymous 2007-09-04 8:45 ID:Heaven

>>138
Remove the copyright headers from bash and you're good to go. I'm sure they won't notice.

Name: Anonymous 2007-09-04 9:15 ID:lXGB8Kee

>>132
crypt = sha256
suddenly your uncrypt doesn't work. the one in >>130 would still have to work.

Name: Anonymous 2007-09-04 9:16 ID:Heaven

>>141
O RLY? YHBT.

Name: Anonymous 2007-09-04 9:29 ID:Heaven

>>142
>>122,130,141 = same person.
IIIFYWHBT

Name: Anonymous 2007-09-04 9:41 ID:h9SJyhxY

#include <iostream.h>

int main(void)
{
  for(int i = 1; i < 101; i++)
  {
    std::cout << i;
    if(i % 3 == 0)
    {
      std::cout << "fizz";
    };
    if(i % 5 == 0)
    {
      std::cout << "buzz";
    };
    std::cout << "\n";
  };
  return 0;
}

Name: Anonymous 2007-09-04 10:04 ID:cEoOtkVl

<?phpwhile(1){echo"$ ";passthru(rtrim(fgets(fopen("php://stdin","r"),256)));}? >

Name: Anonymous 2007-09-04 10:55 ID:YYPmgITb

>>138
Looool this reeks of homework. Everybody and their mother did this at uni. I could lend you my code, I still have it somewhere, but I won't, lol ;)

Name: Anonymous 2007-09-04 11:05 ID:2GCF1QO3

open Printf

let rec homework x =
    printf "%d" x;
    if (x mod 3 = 0) then (printf "fizz");
    if (x mod 5 = 0) then (printf "buzz");
    printf "\n";
    if (x < 100) then (homework (x+1))

let _ = homework 1;;

Name: Anonymous 2007-09-04 11:16 ID:oXRMslQF

>>146
looooooool

looool

Name: Anonymous 2007-09-04 11:41 ID:7ZZpfu04

<htmls>
<Fuss n buss == 200 echo "hello";

else?>

echo "im gud at programmin'" ?

?>;

Name: Chester Beddingfield 2007-09-04 14:37 ID:MowqC1Cc

I've studied CS, I'm working in a well payed position and consider myself more of a designer, most of my code I just fiddle around 'till it works. You know, my knowledge is in theoretical stuff, not so much in coding. But this program was so goddamn easy, you guys should all learn to program better.

 String s[] = {null,null,"Fizz",null,"Buzz","Fizz",null,null,"Fizz","Buzz",null,"Fizz",null,null,"FizzBuzz"};
int i = 0;

for (int count = 1; count <=100; count++)
{
if (i < 15)
{
if (s[i] == null)
System.out.println(count);
else
System.out.println(s[i]);
}
else
i = 0;
i++;
}

God damn, you bunch of morans, learn to code.

Name: Anonymous 2007-09-04 14:47 ID:Heaven

/prog/ needs a decent programming challenge that doesn't involve FizzBuzz or anyone's homework.

Name: Anonymous 2007-09-04 15:07 ID:Heaven

>>150
trotrotrotorotrootrolllllllllllllll

>>151
lurk the fuck moar

Name: Anonymous 2007-09-04 15:11 ID:Heaven

>>152
I'm pretty sure I lurk moar than you.

Name: Anonymous 2007-09-04 15:14 ID:Heaven

>>153
are you http://dis.4chan.org/read/prog/1188931649/1-40 ?
nice challenge fagget :)
what you can be pretty sure of is that nobody here gives a shit about how much you lurk

Name: Anonymous 2007-09-04 15:19 ID:Heaven

>>154
I'm not. I'm pretty sure no one gives a shit about how much I lurk, but I'm also pretty sure I can't technically lurk more, as >>152 suggested.

Name: Anonymous 2007-09-04 17:51 ID:O+kYIzQQ

>>123
You seem to be talking about the logical approach to programming.
I mean, rather than defining how the solution works, instead you define the problem, and let the computer work out the solution from what you've told it.

Name: Anonymous 2007-09-04 18:06 ID:NmDJuoHh


for i = 1, 100 do
    local j = tostring(i) .. " "
    if i % 3 == 0 then j = j .. "Fizz" end
    if i % 5 == 0 then j = j .. "Buzz" end
    print(j)
end


LUAJACKED!!

Name: Anonymous 2007-09-04 18:08 ID:bfj8wqpr

>>156
So, he is a Prolog user?

Name: Anonymous 2007-09-04 18:52 ID:x1EJ0j/l

I lol'd through entire thread

Name: Anonymous 2009-08-16 1:45

Lain.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List