56
\$\begingroup\$

Winner: Aditsu's CJam answer! A whopping 25 bytes! Nice!

You may continue to submit your answer, however you can no longer win. Original post kept for posterity:


The "Bzzt" game is a game where you must count to a number (in this case 500). However, if the number has a 3 in it, or is divisible by 3, you don't say the number. Instead, you say "Bzzt".

Rules:

  • You can't hard-code the numbers.
  • The number only has to satisfy at least 1 of the following requirements
    • Divisible by 3
    • Number contains a 3
  • Some type of separator is mandatory (12bzzt14 doesn't count)
  • Score is measured in bytes.
  • You must count exactly to 500, starting at 1 or 0 (you chose).
  • The numbers must be output, but it doesn't matter how (e.g., stdout, writing to a text file, etc.).
  • 0 can be divisible by 3 or not divisible. You can choose.
  • You can output the numbers one at a time (ex, output 1, then 2, then bzzt, then 4, etc) or all at once (e.g., output 1 2 bzzt 4 5).
  • You must replace the letter 3 with the word "bzzt". This is not case sensitive (bZzt, Bzzt, bzzt are all okay).

  • This is a challenge, so the shortest code wins.
  • This contest ends June 30th 2014 (7 days from posting).
\$\endgroup\$
  • 1
    \$\begingroup\$ For purposes of this question, is 0 divisible by 3? \$\endgroup\$ – Οurous Jun 23 '14 at 7:07
  • 2
    \$\begingroup\$ Is it "buzz" or "bzzt"? You wrote "buzz" twice so far. \$\endgroup\$ – aditsu Jun 23 '14 at 8:40
  • 3
    \$\begingroup\$ Please clarify. Do I have to output buzz or bzzt if both of the requirements apply? Do I have to output 12bzzt4 or bzzt for 1234? \$\endgroup\$ – nyuszika7h Jun 23 '14 at 12:41
  • 4
    \$\begingroup\$ I'd say bzzt for 1234. It's a 'common' drinking game here (only we often do it with 7) \$\endgroup\$ – Martijn Jun 23 '14 at 13:38
  • 66
    \$\begingroup\$ "0 can be divisible by 3 or not divisible. You can choose." I really don't think you can choose. 0 mod 3 is 0, that's not really a matter of opinion. \$\endgroup\$ – David Conrad Jun 23 '14 at 15:54

80 Answers 80

3
\$\begingroup\$

Scala, 70

Code

1 to 500 map(x=>if(x%3<1||(""+x).contains(51))"bzzt"else x)map println

Usage

scala -e '1 to 500 map(x=>if(x%3<1||(""+x).contains(51))"bzzt"else x)map println'

Demo

http://ideone.com/KfcO1M

Explanations

  • 1 to 500: produces values from 0 to 500
  • map: function which takes iterable argument at the left, and applies the function given at the right
  • x=>...: lambda expression
  • if(condition) value_if_condition_is_true else value_if_condition_is_false: returns a value (functional behavior) which can be either a java.lang.String or a scala.Int. The expression type is scala.Any in this case, because this is the lower type the two types can coerce to (see the Scala Class Hierarchy)
  • map println: takes each object (java.lang.String or scala.Int) and prints it with line feeds
\$\endgroup\$
3
\$\begingroup\$

Swift - 74

for i in 0..501 {println(i%3<1||"\(i)".rangeOfString("3") ?"bzzt":"\(i)")}
\$\endgroup\$
3
\$\begingroup\$

05AB1E, 26 23 21 bytes (non-competing)

501FND3ÖN3å~i"bzzt"},

Try it online!

\$\endgroup\$
2
\$\begingroup\$

JavaScript - 57

Another JavaScript example:

for(i=0;i<500;)alert((++i+'').indexOf(3)<0&&i%3?i:'bzzt')
\$\endgroup\$
2
\$\begingroup\$

PROLOG (144)

b:-b(R,1),print([0|R]).
b([500],500).
b([bzzt|R],N):-((0is N mod 3);(name(N,C),member(51,C))),N1 is N+1,b(R,N1).
b([N|R],N):-N1 is N+1,b(R,N1).

Usage:

b.
\$\endgroup\$
2
\$\begingroup\$

Microsoft Small Basic (115 chars, 127 bytes)

For i = 1 To 500
j=i
If(Math.Remainder(i,3)=0 Or Text.IsSubText(i,"3"))then
j="bzzt"
EndIf
TextWindow.Write(j+" ")
EndFor
\$\endgroup\$
2
\$\begingroup\$

Haskell 78

main=mapM(putStrLn.f)[0..500];f x|x`mod`3<1||'3'`elem`show x="bzzt";f x=show x
\$\endgroup\$
2
\$\begingroup\$

Python - 53

for i in range(1,501):print[i,'Bzzt']['3'[:i%3]in`i`]

Can't add comments to above answer so posting down here. Starting range at 0 produces Bzzt at 0, need to start at 1.

\$\endgroup\$
2
\$\begingroup\$

Python2 (59)

Simple case of list comprehension

print[n if n%3or '3'in str(n)else"bzzt"for n in range(501)]
\$\endgroup\$
  • 1
    \$\begingroup\$ With some tips you can get to 52 bytes at least. \$\endgroup\$ – Linus Nov 4 '16 at 3:09
2
\$\begingroup\$

MathGolf, 19 18 bytes

♪½{î3╧î3÷+î╕▄┴_ߧp

Try it online!

Explanation

♪                     push 1000
 ½                    divide by 2, making 500
  {                   start for loop
   î                  index of current loop (1-based)
    3                 push 3
     ╧                pop a, b, a.contains(b)
      î               index of current loop (1-based)
       3              push 3
        ÷             is divisible
         +            pop a, b : push(a+b)
          î           index of current loop (1-based)
           ╕▄┴        decompress "bzzt"
              _       duplicate TOS
               ß      wrap last three elements in array (makes [<index>, "bzzt", "bzzt"])
                §     get from array
                 p    print with newline
\$\endgroup\$
  • \$\begingroup\$ How does the string compression work, and is there some kind of generator program I could use for other strings? Just posted an answer with two strings, but not sure how to do string compression in MathGolf. \$\endgroup\$ – Kevin Cruijssen Jun 3 at 12:27
  • 1
    \$\begingroup\$ The way I do it is that I check the reference page and Code page 437, and I match the column and the row of the character within the code page with the indices of the string I want. So, means indexing in the string etaoinsrdluczbfp. In that string, b has index 13, z has index 12, and t has index 1. Thus, I look at row 13 and column 12 for bz, which is character . Then I look at row 12 and column 1 for zt, which is character . \$\endgroup\$ – maxb Jun 3 at 12:39
  • \$\begingroup\$ Be wary though that it is not strictly Code page 437, since I swapped two characters (the null byte and the non-breaking space). Both of these characters should be replaced with their new counterparts (× and Þ). It should be fairly straight-forward to make a generator program for short strings, I just haven't made one. The compression is nothing fancy, but in cases like this challenge it can save you 2 bytes over the standard ÿbzzt. \$\endgroup\$ – maxb Jun 3 at 12:42
  • \$\begingroup\$ Ah ok. And compressed strings of mixed characters? So partially from etaoinsrdluczbfp and partially from gwymvkxjqh ?*#.,? Or that isn't possible (yet)? To be more concrete, what would the compressed strings for ÿduck and "goose be? (Here a link to my current answer.) \$\endgroup\$ – Kevin Cruijssen Jun 3 at 12:45
  • \$\begingroup\$ I've been able to figure out how to compress "goose to 'g╕3` . As for ÿduck, I guess I could use a 3-char compression for "duc" and a loose 'k, but how does that work when they are in pairs of row-column? EDIT: Never mind, for 3-char it doesn't matter what the column is, but now I have the problem that the strings aren't joined to print. Maybe a different question: how to do a ranged loop without pushing the indexes of the loop? I now have this. \$\endgroup\$ – Kevin Cruijssen Jun 3 at 12:51
1
\$\begingroup\$

bash – 74

I know it won't win anything, not even within bash, but thought I'd submit one where 500 or 501 is not in the solution.

seq 0 166|awk '{print"bzzt\n"($1)*3+1"\n"($1)*3+2;}'|sed 's/.*3.*/bzzt/g'
\$\endgroup\$
1
\$\begingroup\$

F# - 86

for i in 0..500 do if(string i).Contains"3"||i%3=0 then printfn"Bzzt"else printfn"%i"i
\$\endgroup\$
1
\$\begingroup\$

C# (110)

Enumerable.Range(1,500).All(x =>{Console.Write((x%3==0)||(x + "").Contains("3")?"Bzzt ":x+" ");return true;});
\$\endgroup\$
  • \$\begingroup\$ You can get a lower byte count by removing unnecessary whitespace. Actually, you don't need any whitespace here. \$\endgroup\$ – ProgramFOX Jun 23 '14 at 16:31
  • \$\begingroup\$ What version of C# has an IEnumerable<T>.ForEach method? \$\endgroup\$ – Peter Taylor Jun 23 '14 at 16:38
  • \$\begingroup\$ I get an error on Mono's C# compiler: Unexpected symbol: `Enumerable' \$\endgroup\$ – Jwosty Jun 23 '14 at 16:54
  • \$\begingroup\$ (x+"").Contains("3") should work instead of the ToString() to shorten it. \$\endgroup\$ – WozzeC Jun 23 '14 at 19:15
  • \$\begingroup\$ Made the changes, removed ForEach which was a extension method from a 3rd party library. \$\endgroup\$ – stephenbayer Jun 23 '14 at 19:39
1
\$\begingroup\$

Ruby, 57

Not a competitive Ruby answer, but I like it because it's weird.

i=-1;([b=:bzzt,p,p]*167).map{|a|puts"#{i+=1}"[?3]?b:a||i}
\$\endgroup\$
1
\$\begingroup\$

Befunge 93 - idk

Just for fun:

&   > ::::91+/91+*-01p91+/:91+/91+*-: 11p91+91+*/21p >  01g3-  !!     |
   9                                                                  "
30 9g                                                                  
   *4                                                                 t
   90                                                                 z
   5p                                                                 z
   *4                                                                 b
   +0                                                                 "
   3+                                       v                   $,,,,,<
   -*                                                                  
   99                                       v   .<   |    !! -g20g0*87<
   >^                                            |%3:<                p
                                                 "                     
    v               _@#`0: -1   p0*87    g21<                         0
                                                 t                    *
                                                 z   ^                8
                                                 z                    7
                                            $    b                    +
                                            ,    "                    1
                                            ^,,,,<                    g

                                                                      0
                                                                      *
                                                                      8
                                                                      7

Decidedly un-golfyfied, but it was fun creating a complete program.

\$\endgroup\$
1
\$\begingroup\$

PHP, no seperator - 53

while(++$i<501)echo$i%3<1||strpos(-$i,'3')?'bzzt':$i;

It's a improved version of @Martijn's code. I would like to add comment to his answer, but I haven't enough reputation to do that...

\$\endgroup\$
1
\$\begingroup\$

seq and awk 48 38

seq 500|awk '!($1%3)||/3/{$1="bzzt"}1'
\$\endgroup\$
  • \$\begingroup\$ The awk code part could be $1%3&&!/3/||$1="bzzt". \$\endgroup\$ – manatwork Jul 25 '15 at 15:30
1
\$\begingroup\$

Python2 (63)

Corrected version of @idiot.py's code (I don't have enough reputation to comment on his post).

print[n if n%3and'3'not in str(n)else"bzzt"for n in range(501)]

or, equivalently,

print["bzzt"if not n%3or'3'in str(n)else n for n in range(501)]

You have to negate the second condition, otherwise it gives incorrect output.

output:

['bzzt', 1, 2, 'bzzt', 4, 5, 'bzzt', 7, 8, 'bzzt', 10, 11, 'bzzt', 'bzzt', 14, 'bzzt', 16, 17, 'bzzt', 19, 20, 'bzzt', 22, 'bzzt', 'bzzt', 25, 26, 'bzzt', 28, 29, 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 40, 41, 'bzzt', 'bzzt', 44, 'bzzt', 46, 47, 'bzzt', 49, 50, 'bzzt', 52, 'bzzt', 'bzzt', 55, 56, 'bzzt', 58, 59, 'bzzt', 61, 62, 'bzzt', 64, 65, 'bzzt', 67, 68, 'bzzt', 70, 71, 'bzzt', 'bzzt', 74, 'bzzt', 76, 77, 'bzzt', 79, 80, 'bzzt', 82, 'bzzt', 'bzzt', 85, 86, 'bzzt', 88, 89, 'bzzt', 91, 92, 'bzzt', 94, 95, 'bzzt', 97, 98, 'bzzt', 100, 101, 'bzzt', 'bzzt', 104, 'bzzt', 106, 107, 'bzzt', 109, 110, 'bzzt', 112, 'bzzt', 'bzzt', 115, 116, 'bzzt', 118, 119, 'bzzt', 121, 122, 'bzzt', 124, 125, 'bzzt', 127, 128, 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 140, 'bzzt', 142, 'bzzt', 'bzzt', 145, 146, 'bzzt', 148, 149, 'bzzt', 151, 152, 'bzzt', 154, 155, 'bzzt', 157, 158, 'bzzt', 160, 161, 'bzzt', 'bzzt', 164, 'bzzt', 166, 167, 'bzzt', 169, 170, 'bzzt', 172, 'bzzt', 'bzzt', 175, 176, 'bzzt', 178, 179, 'bzzt', 181, 182, 'bzzt', 184, 185, 'bzzt', 187, 188, 'bzzt', 190, 191, 'bzzt', 'bzzt', 194, 'bzzt', 196, 197, 'bzzt', 199, 200, 'bzzt', 202, 'bzzt', 'bzzt', 205, 206, 'bzzt', 208, 209, 'bzzt', 211, 212, 'bzzt', 214, 215, 'bzzt', 217, 218, 'bzzt', 220, 221, 'bzzt', 'bzzt', 224, 'bzzt', 226, 227, 'bzzt', 229, 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 241, 242, 'bzzt', 244, 245, 'bzzt', 247, 248, 'bzzt', 250, 251, 'bzzt', 'bzzt', 254, 'bzzt', 256, 257, 'bzzt', 259, 260, 'bzzt', 262, 'bzzt', 'bzzt', 265, 266, 'bzzt', 268, 269, 'bzzt', 271, 272, 'bzzt', 274, 275, 'bzzt', 277, 278, 'bzzt', 280, 281, 'bzzt', 'bzzt', 284, 'bzzt', 286, 287, 'bzzt', 289, 290, 'bzzt', 292, 'bzzt', 'bzzt', 295, 296, 'bzzt', 298, 299, 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 400, 401, 'bzzt', 'bzzt', 404, 'bzzt', 406, 407, 'bzzt', 409, 410, 'bzzt', 412, 'bzzt', 'bzzt', 415, 416, 'bzzt', 418, 419, 'bzzt', 421, 422, 'bzzt', 424, 425, 'bzzt', 427, 428, 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 'bzzt', 440, 'bzzt', 442, 'bzzt', 'bzzt', 445, 446, 'bzzt', 448, 449, 'bzzt', 451, 452, 'bzzt', 454, 455, 'bzzt', 457, 458, 'bzzt', 460, 461, 'bzzt', 'bzzt', 464, 'bzzt', 466, 467, 'bzzt', 469, 470, 'bzzt', 472, 'bzzt', 'bzzt', 475, 476, 'bzzt', 478, 479, 'bzzt', 481, 482, 'bzzt', 484, 485, 'bzzt', 487, 488, 'bzzt', 490, 491, 'bzzt', 'bzzt', 494, 'bzzt', 496, 497, 'bzzt', 499, 500]
\$\endgroup\$
1
\$\begingroup\$

Tcl 90

set i 0;while {$i < 501} {if {[regexp 3 $i]||($i %3)<1} {puts "bzzt"} {puts "$i"};incr i}

I'm sure other tclers could make this more terse, but the interpreter is funny about whitespaces.

\$\endgroup\$
1
\$\begingroup\$

C, 90 86 81

i,s;main(){while(++i<501)sprintf(&s,"%d",i),puts(i%3&&!strchr(&s,51)?&s:"bzzt");}

Not a serious contender. This is essentially bacchusbeale's answer golfed better, as I suggested in comments to his answer. As well as those changes, I used strchr as a shorter test than a for loop to see if the string version of the integer contains the character 3 (character 51 in ASCII).

Edit: down to 81 characters incorporating edc65's sick trick from the comments (assumes int is at least 32 bits). Thanks!

\$\endgroup\$
  • 1
    \$\begingroup\$ 81: i,s;main(){while(++i<501)sprintf(&s,"%d",i),puts(i%3&&!strchr(&s,51)?&s:"bzzt"); (need a 32 bits int or longer) \$\endgroup\$ – edc65 Jun 25 '14 at 21:43
1
\$\begingroup\$

C, 79

i;main(s){while(++i<498+sprintf(&s,"%d",i))puts(i%3*!strchr(&s,51)?&s:"bzzt");}

Improved version of squeamish ossifrage's solution. Now it's the shortest C solution.

\$\endgroup\$
1
\$\begingroup\$

JavaScript, 70

First entry into a code golf

i=0;while(i<501)console.log(((""+i).match(/3/g)||i%3==0)?'bzzt':i),i++

Can probably be made shorter, but this one doesn't do alert and make you want to kill the developer.

\$\endgroup\$
  • \$\begingroup\$ Count up to 500, for better than while as you use i=0;i++;,alert(once!) better than console.log, test better than match,invert condition to avoid ==0, then you have [codegolf.stackexchange.com/questions/32267/… \$\endgroup\$ – edc65 Jun 26 '14 at 15:54
1
\$\begingroup\$

C#

Code can be executed directly in LinQPad.

Number is divisible by 3 (49)

var i=0;while(i++<501)(i%3<1?"bzzt":i+"").Dump();

This one should count as the question stated:

The number only has to satisfy at least 1 of the following requirements.


Number contains 3 (64)

var i=0;while(i++<501)((i+"").Contains("3")?"bzzt":i+"").Dump();

Both conditions apply (70)

var i=0;while(i++<501)(i%3<1|(i+"").Contains("3")?"buzz":i+"").Dump();
\$\endgroup\$
1
\$\begingroup\$

Delphi - 119

repeat ShowMessage(IfThen((Tag mod 3=0) or (pos('3',IntToStr(Tag))>0),'bzzt',IntToStr(Tag))); Tag:=Tag+1 until Tag=500

Uses the fact that "self" is assumed so the form's Tag property can be accessed directly without actually declaring a variable. I had critiqued another Delphi answer here a few minutes ago so I thought it was only fair I posted one too.

\$\endgroup\$
1
\$\begingroup\$

Delpi - 128

procedure x;var I: integer;begin for I:=0to 500do writeln(iif((IntToStr(i).Contains('3')or(i mod 3=0)),'bzzt',inttostr(i)));end;
\$\endgroup\$
  • \$\begingroup\$ That won't compile. You never declared i. Also there's no iif in Delphi. You must use IfThen(). \$\endgroup\$ – Paul Jun 27 '14 at 21:37
  • \$\begingroup\$ I don't understand why I didnt declare I, maybe I made it a global variable which shouldnt work either.. I'll correct it. But there is an iif in delphi, its in the unit IdGlobal. \$\endgroup\$ – Teun Pronk Jun 30 '14 at 7:16
1
\$\begingroup\$

Java, 127 124 95 bytes

class B{static{for(int i=0;i++<500;System.out.println(i%3<1||(i+"").contains("3")?"Bzzt":i));}}

It throws an exception at the beginning but it works, at least for me (Java version 1.7.0_60-b19 on Mac OS X 10.8.5).

\$\endgroup\$
  • \$\begingroup\$ That trick doesn't work in Java 7 or later. It looks for a main method before executing static initializers. \$\endgroup\$ – tbodt Jun 23 '14 at 21:48
  • \$\begingroup\$ @tbodt I have Java 7 and it works \$\endgroup\$ – stommestack Jun 23 '14 at 21:51
  • \$\begingroup\$ Is there any way you can get a modern toolset to compile and run this, please add it to the answer? (I use 1.7.0_55 on linux) If you need a specific version you need to mention it in your answer. \$\endgroup\$ – Sylwester Jun 23 '14 at 21:52
  • \$\begingroup\$ I tested it on Java 6 (works then throws exception) and Java 8 (doesn't work). \$\endgroup\$ – tbodt Jun 23 '14 at 22:09
1
\$\begingroup\$

LiveScript (54)

for n to 500=>alert if n%3==0||/3/test n=>\bzzt else n
\$\endgroup\$
1
\$\begingroup\$

JAGL V1.0 - 35

1 501r{ddg@3%nSg51e|"bzzt"SnI32+p}/

Probably could have done better. May try to revise it.

Explaination:

1 501r                                     Make a range of 1 to 500 inclusive
      {ddg                                 Duplicate twice and convert top to string
          @3%n                             Rotate top 3 on stack, and push not(top mod 3)
              Sg                           Swap top two values, and convert top to string
                51e                        Check if 51 (3) is in the string rep
                   |"bzzt"                 Take the logical "or", and push "bzzt"
                          SnI              Swap, reverse, and if not divisible, drop "bzzt"
                             32+p          Add a space, and print
                                 }/        End block, and map over range
\$\endgroup\$
1
\$\begingroup\$

Java, 139 132 128 127 bytes

class A{public static void main(String[] a){for(int i=0;i++<500;)System.out.print(i%3==0|(i+"").contains("3")?"bzzt ":i+" ");}}
\$\endgroup\$
  • 1
    \$\begingroup\$ You can shave off a couple of characters by removing the {} braces on your for loop and doing a i++<501;) check. \$\endgroup\$ – Nathan Merrill Jul 2 '15 at 14:14
  • \$\begingroup\$ Sure @NathanMerrill....shortened 'args' variable name as well \$\endgroup\$ – Utsav Jul 2 '15 at 14:28
  • 1
    \$\begingroup\$ Too many parenthesis: both % and == have higher precedence than || and all of them have higher precendece than ?:: System.out.print(i%3==0||(i+"").contains("3")?"bzzt ":i+" "). \$\endgroup\$ – manatwork Jul 2 '15 at 14:50
  • \$\begingroup\$ well said @manatwork I never cared/thought about using precedence before. Will keep in mind for code-golf \$\endgroup\$ – Utsav Jul 2 '15 at 15:13
  • \$\begingroup\$ As now it became too similar to Jop V.'s Java answer, here is another trick: use bitwise | instead of logical ||. In this case gives the same result. \$\endgroup\$ – manatwork Jul 2 '15 at 15:21
1
\$\begingroup\$

Mouse-2002, 34 bytes

I'm proud that lil' ol' Mouse, first implemented in 1979 and the most recent iteration updated Aug '07 (excluding the one by me), can do so well! :')

(x.501<^x.d\[x.!J!'|"bzzt!"]x.1+x:)

Explained:

(             ~ while true
  x. 501 < ^  ~ push x; push 1 if less than 501 and break if 0
  x. d \      ~ push x mod 3
  [           ~ if 0; then
    x. ! J!'  ~ push x and print, push the ascii code 9 and print
  |           ~ else
    "bzzt!"   ~ print this string
  ]           ~ endif
  x. b+ x:    ~ push x, increment by 1
)             ~ endwhile
$             ~ (implicit for scripts) end prog

Sample run:

$ mouse bzzt.mou | head
bzzt
1       2       bzzt
4       5       bzzt
7       8       bzzt
10      11      bzzt
13      14      bzzt
16      17      bzzt
19      20      bzzt
22      23      bzzt
25      26      bzzt

Tab chars because I say so.

My reboot of this language's legacy can do this exact thing in 27 bytes:

(x501<^xd\[x.|"bzzt".]1!x+)

And I'm not even aiming for it to be a golfing lang, just a small syntax! No interpreter yet.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.