Code:
: prog1 20 1 do 0 i 3 mod 0= if ." fizz" drop 1 then i 5 mod 0= if ." buzz" drop 1 then 0= if i . else ." " then loop ;
|
Mentor
|
![]() |
| 28May2009,14:04 | #11 |
|
And a better one that doesn't use variables:
Code:
: prog1 20 1 do 0 i 3 mod 0= if ." fizz" drop 1 then i 5 mod 0= if ." buzz" drop 1 then 0= if i . else ." " then loop ; |
|
Go4Expert Member
|
|
| 28May2009,14:49 | #12 |
|
Code:
<?php
for($i = 1; $i <= 100; $i++)
{
echo (($i%3 ==0) && ($i%5 ==0)) ? 'FizzBuzz<br>' : (($i%3==0) ? 'Fizz<br>' :(($i%5==0) ? 'Buzz<br>' : "$i<br>"));
}
?>
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 28May2009,17:55 | #13 |
|
@ xpi0t0s : Please do mention the language (atleast in your code-block), before posting any code.
BTW, that code looks like Forth, am I right ?? One more by me : (in HLA = High Level Assembly) Code: asm
Last edited by SaswatPadhi; 28May2009 at 19:21.. Reason: Added HLA Code |
|
Mentor
|
![]() |
| 28May2009,19:24 | #14 |
|
Quote:
Originally Posted by SaswatPadhi Quote:
Originally Posted by xpi0t0s |
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 28May2009,20:13 | #15 |
|
Oh !
: , I didn't see it ![ Bad habit of jumping to the last post, directly ] |
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 1Jun2009,07:09 | #16 |
|
Finalllyyyy... After struggling with BrainF*ck for 3 hours, I conclude that the language truly justifies its name !
Here is my BF code for some thing as simple as a Fizz-Buzz test : Code:
< * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # * (+) FIZZ-BUZZ PROGRAM BY SASWAT PADHI > * # # * * # # * This BrainF*ck program is written by Saswat Padhi * # # * I have done much labour on this code as writing a * # # * BF code is not easy; even harder than ASM ;) * # # * * # # * Believe it or not I have spent 3 hours writing this * # # * shit(looking) code ! * # # * * # # * If you want to use this code; please give me some * # # * credit by atleast mentioning my name :) Thanks * # # * * # # * PLEASE NOTE THAT THIS IS THE UNCOMMENTED VERSION OF * # # * MY ORIGINAL FIZZBUZZ PROGRAM; SO BETTER NOT TO TRY * # # * READING IT ;) IF YOU WANT A MORE HUMAN_FRIENDLY * # # * VERSION THAT IS WELL COMMENTED; YOU MAY CONTACT ME * # # * * # # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # > ************************************************************************ ******************** FIZZBUZZ BF SOURCE CODE BEGINS ******************** ************************************************************************ ** ** ** ** ** >++++++++++++++++++++++++++++++++++++++++++++[[>]+++++++++++++++ ** ** ++++++++++++++++++++++++++++++++++++++++++++++++++[<]>-]>+++++.> ** ** ++++++++.>+++++++++++++++++++++++++.>+++++++++++++++++++++++++.> ** ** --------------------.>+.>++++++++++++++++++++.>+++++++++++++++++ ** ** ++++++++.>+++++++++++++++++++++++++.>--------------------------- ** ** ------.>+++++++++++++++.>+++++++++++++++++.>++++++++++++++.>++++ ** ** ++.>+++++++++++++++++.>.>++++++++++++.>------------------------- ** ** --------.>+.>++++++++++++++++++++++++.>------------------------- ** ** --------.>++++++++++++++++++.>.>++++++++++++++++++.>++++++++++++ ** ** ++++++++++.>.>+++++++++++++++++++.>----------------------------- ** ** ----.>+++++++++++++++.>.>+++.>+++++++.>++++++++.>--------------- ** ** ----------------------------------------..>--------------------- ** ** -------------------------------------------->+++++>++++++++>++++ ** ** +++++++++++++++++++++>+++++++++++++++++++++++++>---------------- ** ** ------------------------------------------------->+>++++++++++++ ** ** ++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>>++ ** ** ++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++>+++++ ** ** ++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++> ** ** >>>>>>>>>++<<<<<<<<<<<<<<[>++++++++++>>----------<<[>>+>>[-]>[-] ** ** >[-]>[-]+>[-]+>[-]+>[-]>[-]>[-]>+>[-]<[>+>+<<-]>>[<<+>>-]<<---[< ** ** <<<<<[-]>>>>>[-]+>-]<[>>[<+>-]>+<<<-]>>>[<<<+>>>-]<<<<<<<<<<<<<[ ** ** >>+>+<<<-]>>>------------------------------------------------[>> ** ** >[-]>>[-]+<<<<+<-]>[<+>-]<-----[>>>>[-]>>[-]+<<<<<<-]<[<<+>>-]>> ** ** >[<<<<<<<<<<[<]<[<]>.>.>.>.>>>>>>>>>>>>>>>-]>[<<<<<<<<<<<[<]>.>. ** ** >.>.>>>>>>>>>>>-]>[<<<<<<<<<<<<[<]>.>.>.>.>>>>>>>>>>>>-]>[>[>[<< ** ** <<<<<<<<<.>.>>>>>>>>>>-]<-]<-]<<<<<<<.<<<-]>+<<-]<<[<]>.>.>.>.<> ** ** ** ** ** ************************************************************************ ******************** END OF FIZZBUZZ BF SOURCE CODE ******************** ************************************************************************ Program Size :: 4254 bytes Instructions :: 1669 Number of moves :: 694083 Average RunTime :: 30 ms Notes : (*) Compile with option "Allow wrapping of pointers = TRUE" (*) Compile with option "Allow wrapping of values = TRUE" |
|
Go4Expert Founder
|
![]() |
| 1Jun2009,09:58 | #17 |
|
Thats really a BrainF*ck really
|
|
Team Leader
|
![]() |
| 1Jun2009,11:15 | #18 |
|
:O That's some code. For people who don't know about Brain*uck check this link http://cydathria.com/bf/
|
|
Team Leader
|
![]() |
| 1Jun2009,11:19 | #19 |
|
Code: JavaScript
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 1Jun2009,11:38 | #20 |
|
Code: QBASIC
|