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".
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.
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 )
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?
>>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
>>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:
Anonymous2007-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))
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++;
}
>>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:
Anonymous2007-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:
Anonymous2007-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