text:
Implement FBLint
(FB, or Functional-Basic, as found here Interpret Functional-Basic)
Task
Implement a linting program for FB, similar to JSLint for JavaScript.
Error types
Invalid identifier
Identifiers can only have upper and lower case ASCII letters.
Locations:

The identifier right after a let expression
The identifier in a for loop

Examples:
for (? in b) <-- ? is invalid
let b_b8 = ... <-- b_b8 is invalid

Undefined identifier
If you encounter an identifier that has not been defined in either a let expression or a for loop. Note that the identifier in a for loop only count in the expression following it.
Location:

Anywhere an identifier is used

Example program:
let b = a <-- nope
for (x in a) x+1 <-- nope, still don't know what `a` is
print x <-- gotcha! `x` is out of scope here

Unexpected EOL
End of line is the deliminator for statements in FB, so you can't have a statement span multiple lines (even if it's surrounded by parenthesis ()). Use this if you expected more but encountered a EOL char.
Locations:

Any line

Examples:
let b <-- missing the `= [statement]`
for ( <-- missing `x in y) [statement]`
print <-- print what?
print print sum <-- sum what?

Unexpected token
This is best explained by examples.
Locations:

Any line

Examples:
print * 2 <-- What is `*2` doing for me? I need a statement!
3**5      <-- `3*` expects a number, not a `*` symbol
for x in y <-- a little diffrent, but for
                     expects a pren `(`, not x

Improper type
Used when a list is expected and a number was encountered, or when a number is needed and you get a list. Lists in FB are only allowed to have numbers or other lists as children, so errors can occur here as well. Note that if you find an identifier that is valid, you should perform this check based on the id's type.
Locations:

Function application
for loops
The +-*/^ operators
List literal creation

Examples:
let y = [5]
let z = y + [[], [6]] <-- invalid, y is a list of numbers, right
                            hand side is a list of lists
print y + 1           <-- y is a list, not a number
sum 1                 <-- sum takes a list, not a number
[5] - [5]             <-- invalid, subtraction doesn't apply to lists
1 + []                <-- addition doesn't work with a list and a number
for (digit in 12) ... <-- `for` takes a list
let list = [00, 00]
let nlst = [list, 1]  <-- invalid
[1, []]               <-- invalid

Multiple assignment
This is when a for loop or let statements identifiers overlap with a currently defined identifier.
Locations:

In a for loop
In a let statement

Examples:
let y = 8
let y = 5 <-- invalid, y is already defined
for (y in []) <-- invalid, y is already defined
for (x in []) ...
let x = 8 <-- valid since the `x` in the for loop is out of scope

Nested for loop
Again, pretty self explanatory. FB doesn't allow nested for loops.
Locations:

In for loops

Examples:
for (x in [[1, 5], [2, 8]]) for (y in x) x*y <-- just invalid

Input format
If you are writing a function, you will receive one multi-line string. If you are writing a full program, you must take a multi-line input.
Output format
Output format is simply the error title, followed by the line number the error occurs on. You must show all errors in the program.
Format:
[error title] on line [line number, 1-indexed]

Example
This is one large example that should show all possible error types and outputs. Please let me know if I missed something.
Input
let bb8 = 0
let bbEight = lst

for (x in
let x = 5*/5
let y = 4
let z = [5, 6] + y
let y = [[4]] + [y]
for (x in [[y, y+1], 5]) for (y in x)

Output
Invalid identifier on line 1
Undefined identifier on line 2
Unexpected EOL on line 4
Unexpected token on line 5
Improper type on line 6
Improper type on line 7
Multiple assignment on line 7
Nested for loop on line 8
Multiple assignment on line 8
Multiple assignment on line 8
Improper type on line 8
Unexpected EOL on line 8

Note that thees checks may come in any order, and if the same error occurs multiple times on the same line, you must print the error multiple times as well.
I hope this isn't to difficult
Edits
I have removed the Empty line error since it didn't make sense, and nobody is working on the problem (to my knowledge).

Python3, 2381 bytes:
import re
N=lambda x:next(x,0)
G={'sum':[[2,1],1],'product':[[2,1],1],'print':[-1,[2]]}
P={'+':[(1,1),(2,2)]}
def s(l):
 r=[]
 while l:r+=[j:=re.search('\w+|\(|\)|\=|\+|\-|\*|/|\^|\[|\]|,|\s+|\W+',l).group()];l=l[len(j):]
 return filter(lambda x:x.strip(),r)
M=['Invalid identifier','Undefined identifier','Unexpected EOL','Unexpected token','Improper type','Multiple assignment','Nested for loop']
B=lambda x:x if int==type(x)else x[0]
F=lambda I,n:M[I]+f' on line {n}'
def O(l,n,E,t=-1,c=2):
 if l==0:c=2
 if t==-2:c=c
 if (t==-1 and l)or l==t:return l
 E(F(c,n));raise Exception
def A(b,s,k,v):
 if v:b[s][k]=v
def X(l,n,s,b,E,C,L=0,W=0):
 v,U=0,0
 while 1:
  if(k:=N(l))==0 and v:break
  if O(k,n,E)not in[')',']']:
   if k in'+-*/^':
    if v==0:O(1,n,E,-2,3)
    V,l=X(l,n,s,b,E,C)
    if(B(v),B(V))not in P.get(k,[(1,1)])or v!=V:O(1,n,E,-2,4)
    v=V;U=1
   elif U and k!=',':O(0,n,E,-2,3)
   elif k==',':l=iter([k,*l])
   if'for'==k:
    if L:E(F(6,n))
    v=C(iter([k,*l]),n,s,b,E);U=1
   elif'('==k:
    v,l=X(l,n,s,b,E,C);O(N(l),n,E,')',2);U=1
   elif k.isalpha():
    if k in G:
     V,l=X(l,n,s,b,E,C,0,1)
     if V==0:O(0,n,E)
     if G[k][0]!=-1 and G[k][0]!=V:O(1,n,E,-2,4)
     v=G[k][1];U=1
    else:
     if k not in b[s]:O(1,n,E,-2,1)
     v=b[s][k]
    U=1
   elif k.isdigit():
    v=1;U=1
   elif'['==k:
    L=[]
    while 1:
     V,l=X(l,n,s,b,E,C)
     if V:
      L+=[V]
      if(k:=N(l))==']':v=L;break
      O(k,n,E,',',3)
     else:O(O(N(l),n,E),n,E,']',3);break
    if(_:=len(Y:=set(map(str,L))))==1:v=[2,eval([*Y][0])]
    else:
     if _>1:E(F(4,n))
     v=[2]+([]if[]==L else[-1])
    U=1
   else:break
   if U and W:break
  else:l=iter([k,*l]);break
 return v,l
def p(l,n,s,b,E):
 k=N(l)
 if'let'==k:
  if O(k:=N(l),n,E).isalpha()==0:E(F(0,n))
  else:
   if(I:=(k in b[s])):E(F(5,n))
   O(x:=N(l),n,E);O(x,n,E,'=',3);V,l=X(l,n,s,b,E,p)
   if not I:A(b,s,k,V)
 elif'for'==k:
  O(N(l),n,E,'(',3);O(x:=N(l),n,E);O(1,n,E,x.isalpha(),0);O(m:=N(l),n,E);O(m,n,E,'in',3)
  if x in b[s]:E(F(5,n))
  V,l=X(l,n,s,b,E,p)
  O(V,n,E);O(N(l),n,E,')',2)
  if type(V)==int:E(F(4,n))
  V,l=X(l,n,(0,n),{**b,(0,n):{x:V if type(V)==int else V[1]}},E,p,1);O(V,n,E);return[2,V]
  return[2]
 elif k in G:l=iter([k,*l]);V,l=X(l,n,s,b,E,p)
def D(l):
 b,E={(0,):{}},[]
 for i,a in enumerate(filter(None,l.split('\n')),1):
  try:p(s(a),i,(0,),b,E.append)
  except:1
 return E

Try it online!

2320

You sir are an archaeologist.


text:
Build a 4-vertex Connectedness Tester using NAND gates
A connected graph is a graph that contains a path between any two vertices.
Challenge
Build a [2-input NAND-gate] circuit that determines whether a 4-vertex graph is connected.

(A gate's 2 inputs can be the same input bit or other gate.)

Output True if the graph is connected, and False otherwise.
Input
The six possible edges of a simple graph with 4 vertices:
[ 0e1 , 0e2 , 1e2 , 0e3 , 1e3 , 2e3 ]
where aeb represents whether there is an edge between vertices a and b
Connectedness is equivalent to the following conditions:

If less than 3 inputs are True then output False.

If more than 3 inputs are True then output True.

If exactly 3 inputs are True and they form a triangle then output False.

Otherwise, output True.

The answer that uses the fewest gates wins.  Ties will be broken by

the lowest circuit depth (length of longest path(s) from input to output).

Could you specify the input format further?

iej is True or False according to whether there is or isn't an edge from vertex i to vertex j.

Can input be taken as 0 and 1? How about output?

@TheCoffeeCup This is a logic circuit design problem, not [tag:code-golf].

@ThomasKwa Whoops, did not notice.

Why such a small input space?

@MichaelKlein :  It seemed like enough optimization would already be possible with only 4 vertices.

Can the output of a gate be used for multiple other gates? Equivalently, can we save the result of a partial computation to a variable? Also, do we have access to the constants 0 and 1?

@xnor :    Yes.  Since a "gate's 2 inputs can be the same input bit or other gate", [a gate that has exactly one constant-1 input can be replaced with a gate that doesn't have any constant-1 inputs] and otherwise, a gate with one or two constant inputs can be removed.  Since there are connected 4-vertes graphs and disconnected 4-vertex graphs, the output node can't be a constant, so by induction, "the constants 0 and 1" can't help.

Can a gate have more than two inputs?

@LegionMammal978 :  No.

30 NANDS
Instead of asking when do we get a 1, I asked the question when do we get a 0. It's better to ask it this way round because there are less 0's than 1's.
Here's the distribution according to number of edges (6th row of pascal's triangle)
Edges     0  1  2  3  4  5  6
Frequency 1  6 15 20 15  6  1 (total 64)
Output    0  0  0  *  1  1  1
* = 0 if triangle (4 possibilities) 1 if claw (4 possibilities)
1 if two opposite edges and one other (12 possibilities)

Asking the question this way round, we get the following diagram and expression
 ___D___
|\     /|
| E   F |
|  \ /  |
A   X   C
|  / \  |
| /   \ |
|/__B__\|

(A|C|D|B)&(A|D|E)&(D|B|E|F)&(C|B|E)&(A|C|E|F)&(D|F|C)&(A|F|B)

We assume the output will default to 1, but will change to 0 under any of the following conditions
1.A 0 for three adjacent edges (test 3 inputs)
2.A 0 for two opposing pairs of edges (test 4 inputs)
The terms above are already ordered in the manner that will enable them to be grouped as below. (Incidentally, this version of the expression is rotationally symmetrical abouth the AFB vertex.)
((A|D)|((C|B)&E))&((B|E)|((D|F)&C))&((C|F)|((A|E)&D))&(A|F|B)    =6 inverters
   1      1  1       1      1  1       1      1  1      1        =10 (7 OR with both inputs inverted, 3 NAND)
      2                 2                 2               2      =8  (4 OR with one input inverted)
                 2                 2                 2           =6  (3 AND)
                                                        Total    =30

The score for each & or | is placed below the symbol and justified as follows:
Level 0: We invest in an inverter for each input: 6 NANDS
Level 1: We can build an OR from a NAND gate by putting an inverter at the input (total 3 NANDS) but as we already invested in 6 NANDS in the previous step we can make 7 OR gates from 7 NAND gates. We also need 3 AND gates. For these, we will just use NANDs and leave the output inverted. 10 NANDS
Level 2:  Again we build 4 OR gates from NAND gates. In each case we have 1 input from an OR gate, so we have to invert that. But the other input is already inverted (coming from one of the NANDs in the previous step that corresponds to a & symbol in three cases, and from an inverter in the last one) so we only need 2 gates for each OR functionality. 4 * 2 =8
Level 3: We now need to AND the four outputs together. This requires 3 AND gates, each built from 2 NANDs,  3 * 2 = 6
That's a total of 30 NAND gates, with a max depth of 2+2+4=8 NANDs for branches with an | at level 1 or 3+1+4=8 NANDs for branches with an & at level 1.
The following Ruby script confirms visually that the above expression is valid.
64.times{|i|
  a=i%2
  b=i/2%2
  c=i/4%2
  d=i/8%2
  e=i/16%2
  f=i/32%2

puts i, ((a|d)|((c|b)&e))&((b|e)|((d|f)&c))&((c|f)|((a|e)&d))&(a|f|b)

puts " ___#{d}___
|\\     /|
| #{e}   #{f} |
|  \\ /  |
#{a}   X   #{c}
|  / \\  |
| /   \\ |
|/__#{b}__\\|

"
}

19 NANDs
There is no simpler circuit than this.
There is code for testing it below the picture.
As for understanding it, that's difficult.
There are a couple of IF gates there, and the inputs are kinda grouped into a triangle with the free corner lines added for analysis one by one, but not in a simple way. If anyone manages to understand it, I will be impressed.

Verilog code with testing:
// 4-vertex Connectedness Tester
// Minimal at 19 NANDs
//
// By Kim Øyhus 2018 (c) into (CC BY-SA 3.0)
// This work is licensed under the Creative Commons Attribution 3.0
// Unported License. To view a copy of this license, visit
// https://creativecommons.org/licenses/by-sa/3.0/
//
// This is my entry to win this Programming Puzzle & Code Golf
// at Stack Exchange:
// https://codegolf.stackexchange.com/questions/69912/build-a-4-vertex-connectedness-tester-using-nand-gates/
//
// I am sure there are no simpler solutions to this problem.
// It has a logical depth of 11, which is deeper than
// circuits using a few more NANDs.

module counting6 ( in_000, in_001, in_002, in_003, in_004, in_005, in_006, out000 );
  input  in_000, in_001, in_002, in_003, in_004, in_005, in_006;
  output out000;
  wire   wir000, wir001, wir002, wir003, wir004, wir005, wir006, wir007, wir008, wir009, wir010, wir011, wir012, wir013, wir014, wir015, wir016, wir017;

  nand gate000 ( wir000, in_000, in_000 );
  nand gate001 ( wir001, in_001, in_003 );
  nand gate002 ( wir002, wir001, wir000 );
  nand gate003 ( wir003, in_002, wir002 );
  nand gate004 ( wir004, wir002, wir002 );
  nand gate005 ( wir005, wir004, in_002 );
  nand gate006 ( wir006, wir005, wir004 );
  nand gate007 ( wir007, in_005, wir006 );
  nand gate008 ( wir008, in_003, wir006 );
  nand gate009 ( wir009, in_004, wir003 );
  nand gate010 ( wir010, wir003, wir009 );
  nand gate011 ( wir011, wir009, wir000 );
  nand gate012 ( wir012, wir011, in_001 );
  nand gate013 ( wir013, wir008, wir012 );
  nand gate014 ( wir014, wir013, in_005 );
  nand gate015 ( wir015, wir006, wir013 );
  nand gate016 ( wir016, wir015, wir007 );
  nand gate017 ( wir017, wir016, wir010 );
  nand gate018 ( out000, wir014, wir017 );
endmodule

module connecting6_test;
   reg [5:0] X;
   wire a;

  counting6 U1 (
  .in_000 (X[0]),
  .in_001 (X[1]),
  .in_002 (X[2]),
  .in_003 (X[3]),
  .in_004 (X[4]),
  .in_005 (X[5]),
  .in_006 (X[6]),
  .out000 (a )
  );

  initial begin
    X = 0;
  end

  always
    #10  X = X+1;

 initial  begin
    $display("\t\t     \t_");
    $display("\t\ttime,\t \\db/_,\tconnected");
    $monitor("%d,\t%b,\t%d",$time, X, a );
  end

  initial
   #630  $finish;

endmodule

// iverilog -o hello hello.v
// vvp hello

Kim Øyhus

Did you prove this minimal, and if so how?

I used statistical testing to get evidence that it is minimal. For relatively simple circuits, like this one, the tests are fairly certain.

Mathematica, 17 gates
We simply enumerate all of the rules, construct the boolean function, and minimize it in NAND form.
#->If[Total@#<3||
       MemberQ[{{1,1,1,0,0,0},{1,0,0,1,1,0},{0,1,0,1,0,1},{0,0,1,0,1,1}},#]
       ,0,1] /.{1->True,0->False}& /@
     Tuples[{0,1},6];
BooleanMinimize[BooleanFunction[rule], "NAND"]

Result:
(#1⊼#2⊼#4)⊼(#1⊼#2⊼#5)⊼(#1⊼#2⊼#6)⊼(#1⊼#3⊼#4)⊼ \
(#1⊼#3⊼#5)⊼(#1⊼#3⊼#6)⊼(#1⊼#4⊼#6)⊼(#1⊼#5⊼#6)⊼ \
(#2⊼#3⊼#4)⊼(#2⊼#3⊼#5)⊼(#2⊼#3⊼#6)⊼(#2⊼#4⊼#5)⊼ \
(#2⊼#5⊼#6)⊼(#3⊼#4⊼#5)⊼(#3⊼#4⊼#6)⊼(#4⊼#5⊼#6)&

, where #1...#6 are 6 slots for arguments.

Test cases:
f=%; (* assign the function to symbol f *)

f[True, True, True, True, False, False]
(* True *)

f[True, True, False, True, False, False]
(* True *) (*, three Trues do not form a triangle *)

f[True, True, True, False, False, False]
(* False *) (*, three Trues form a triangle *)

Does p⊼q⊼r mean not (p&q&r)?  What does your result's final & mean?

@RickyDemer Yes, p⊼q⊼r means (p⊼q)⊼r, which is equivalent to !(p&&q&&r).

Plugging in False,False,True appears to show that (p⊼q)⊼r is not equivalent to !(p&&q&&r).

@RickyDemer That's a problem... I took it for granted.

Also, at least the wolframalpha version of BooleanMinimize[expr,"NAND"] does not necessarily minimize the number of NANDS.  (Try BooleanMinimize[(((a NAND b) NAND (c NAND d)) NAND ((e NAND f) NAND (g NAND h))),"NAND"].)  Does running that on Mathematica give an output with at most 7 NANDS?

@RickyDemer No, it doesn't. I just understand "minimal-length representation" in the documentation perceptually, and believe it to be optimal in some way. :P

Well, in any case, what does your result's final & mean?

@RickyDemer Your first comment is correct. if p⊼q⊼r is counted as one nand gate, the score is actually 17 gates.

Does your result's final & mean anything?

@RickyDemer It indicates that the whole expression is a "pure function", and has nothing to do with logical AND.

Let us continue this discussion in chat.

(I just edited the question to specify that each gate takes 2 inputs.)  Even for unbounded-fanin NAND gates, your answer would still be beaten by: 6 NANDS to negate each input, 7 NANDS to cover the 4 claws (the complements of the triangles) and 3 2K2s (claw-free things with 4 edges), 1 NAND applied to those 7, and a final NAND on top.

64 NANDs
The six edges can be split up into three pairs of opposite edges. For a graph to be connected, there must either be two opposite edges as well as a third edge, or three edges connected to the same vertex.
       •
       U

   Z   •   Y
    V     W
 •     X     •

The opposite pairs are UX, VY, WZ, so:
A = U+V   ;3 gates
B = W+X
C = Y+Z

D = UV(B+C)  ;2+2+3=7 gates
E = WX(A+C)
F = YZ(C+A)

Result = D+E+F+UVW+UYZ+XVZ+XWY ; 18 + 16 = 34 gates

Building AND and OR gates in the usual way, the total number of gates used is 3*3+7*3+34 = 64.

[True,True,False,True,False,False] gives a connected graph without any opposite edges.

@RickyDemer I think this works now...

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
What's the Language?
Recently, the PPCG design leaderboard has been having some trouble parsing answer html headers.
In this challenge you'll be taking your own shot at parsing answer headers.

Example Test Cases
These example inputs (NOT actual test cases), just so you can get the idea of how inputs might be like
Input:
Python 3, 32 bytes

Desired Output: Python 3

Input:
JavaScript, 13 chars / 32 bytes

Desired Output: JavaScript

Input: VeryBadlyFormattedHeader v3 : (32 bytes)

Spec
Your program should be 150 bytes or below
You will be given a line of an answer header's html, you'll need to try to do your best to successfully extract the language. Input may contain unicode characters.
Output case matters.
Tests
Github Gist with test cases
There is one test case per line. The format is:
<lang_name> - <rest_of_the_line_is_the_header>

Scoring
Your score is:
 Number Correct
----------------
  Total Number

(which is a percent)
Tie-breaker is shortest code.

There should be a tie-breaker like shortest code since 100% score is very achievable.

The most common header style # is not even present in the test cases ?!

So the language is typically the first word the the input?

@edc65 I believe this is about parsing the HTML output of the answer, not the Markdown source.

@Kroltan uh thanks for clarifying

Parsing HTML with regex? Whatever next?

You should have made them output the byte number as well, that's been causing us just as much trouble...

@ETHproductions That could be made into a separate challenge considering its different enough

I would highly recommend changing the tie-breaker from shortest code to earlier submission. Here's why.

Retina 0.8.2, 100%, 75 71 70 68 67 64 59 53 51 bytes
<.*?>

(,| [-&(–5]| [0-7]\d)(?! W|...\)).*

2 |:

This is essentially code golf now, so I had to switch languages.
Try it online!
Verification
$ wget -q https://gist.githubusercontent.com/vihanb/1d99599b50c82d4a6d7f/raw/cd8225de96e9920db93613198b012749f9763e3c/testcases
$ grep -Po '(?<= - ).*' < testcases > input
$ grep -Po '^.*?(?= - )' < testcases > output
$ mono retina/Retina.exe headers.ret < input | head -n -1 | diff -s - output
Files - and output are identical

How it works
The code consists of three simple substitutions (or eliminations). Instead of trying to match the language name, we get rid of all parts of the input string that do form part of it.

<.*?> will match all HTML tags, so the substitution will eliminate them from the input.
.*? matches any amount of characters, but since ? makes the quantifier lazy, it will match the least amount possible that still allows the entire pattern to match. This avoid deleting the entire input, which will always begin with a < and end with a >.
The language name now begins with the first character of the remaining modified input string.
After the language's name, we will almost always find one of the following endings:
,, -, &, (, –, 5, or a space followed by two digits.
The first two endings are rather common, and Python 2 & PuLP... should be parsed as Python 2, Ruby (2.2.2p95)... as Ruby, >PHP – 3302 bytes as PHP, and Perl 5... as Perl.
(,| [-&(–5]| \d\d).* would match all these endings (and all characters after them), but it will result in a few false positives:

, will match the comma in the language name Help, WarDoq!.
( will match the version of JavaScript (ESx) and Java (1.8).
\d\d will match the version in Ti-Basic 84.

We can fix the third problem case by using [0-7]\d instead of \d\d, to avoid matching the 8 in 84.
For the other problem cases, we use the negative lookahead (?! W|...\)) that will prevent the preceding pattern from matching if it is followed by W (as in Help, WarDoq!) or by exactly three characters and a closing parenthesis (as in (ES6) or (1.8)).
Putting it all together, (,| [-&(–5]| [0-7]\d)(?! W|...\)).* matches everything after the language name.
We're left with two problem cases:

Python <s>2</s> 3, <s>255</s> <s>204</s> <s>180</s> 178 bytes

Zozotez Lisp: 73

gets parsed as
Python 2 3
Zozotez Lisp:

We can fix the first by removing 2  and the second one by removing : from the output.
This is achieved by replacing 2 |: with the empty string.

Bash, 100%, 100 bytes
sed sX..s.2./s.XX|grep -Po '(?<=>)[^<]+?(?=(,(?! W)| [-&–5]| ?<| [0-79]\d| ?\((?!E|1\.)))'|head -1

Try it online on Ideone.
Verification
$ wget -q https://gist.githubusercontent.com/vihanb/1d99599b50c82d4a6d7f/raw/cd8225de96e9920db93613198b012749f9763e3c/testcases
$ grep -Po '(?<= - ).*' < testcases > input
$ grep -Po '^.*?(?= - )' < testcases > output
$ while read line; do bash headers.sh <<< "$line"; done < input | diff -s - output
Files - and output are identical

Huh, I really thought this would very difficult... nice job!

CJam, 78.38% (76 bytes)
l{_'>#)>_c'<=}g_'<#<_{",-"&}#)_{_1$=',=+(<}{;}?

Try it online! or count the correct headers.

Jolf, 13 bytes, 85.94%, noncompeting
ρΥpΔid=',H',E
  pΔi         remove all HTML tags from input, preserving content
 Υ   d=',H     slice from beginning until a member is a comma
ρ         ',E  replace said comma with the empty string

I had this update on my computer. It was to my chagrin that I had forgotten to update the respective code for the interpreter. I don't feel like shooting for 100%. Maybe everyone should format their headers the same ¯\_(ツ)_/¯

Stripping tags is a good idea. That saved three bytes in my Retina answer.

@Dennis Thanks! Glad it helped.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Equivalence classes on the Transitive Closure of a Reflexive Relation
The goal of this challenge is to compute the set of equivalence classes over the transitive closure of a symmetric, reflexive relation. For those who don't know what that means, here is a brief introduction into the relevant terms:
A relation ◊ is symmetric if a ◊ b ↔ b ◊ a. It is reflexive if each object is related to itself, i.e. a ◊ a  always holds. It is transitive  if a ◊ b ∧ b ◊ c → a ◊ c, i.e. if a is related to b and b is related to c, then a is related to c. An equivalence relation is a relation that is symmetric, reflexive and transitive.
The transitive closure ◊* of ◊ is a transitive relation such that a ◊* b holds if and only if there is a (possibly empty) series of objects c1, c2, ..., cn such that a ◊ c1 ◊ c2 ◊ ··· ◊ cn ◊ b. The transitive closure of a symmetric, reflexive relation is an equivalence relation.
Let ≡ be an equivalence relation over the set S. An equivalence class a≡ of an object a over the relation ≡ is the largest subset of S such that a ≡ x for all x ∈ S or formally: a≡ = { x | x ∈ S, a ≡ x }. All elements of a≡ are equivalent to one another.
The set of equivalence classes S/≡ of ≡ over S is the set of equivalence classes of all members of S.
Constraints
In this task, your objective is to write a function that takes a binary relation ≅ and a finite non-empty set S. You may take input in a suitable way and choose a suitable data-structure for S (e.g. an array or a linked list). Assume that ≅ is a symmetric, reflexive relation over S. Your function should return or print out the set of equivalence classes over S of the transitiveclosure of ≅. You may choose a suitable output format or data structure for the result. As the result is a set, each object in S may appear only once.
You may not use library routines or other builtin functionality to find the components of a graph or related things.
Winning condition
The shortest answer in octets wins. The most elegant answer is chosen in case of a tie.
Sample input
The reflexive and symmetric members of ≅ have been omitted for brevity.
S1 = {A, B, C, D, E, F, G, H}
≅1 = {(A, B), (B, C), (B, E), (D, G) (E, H)}
S1/≅1* = {{A, B, C, E, H}, {D, G}, {F}}.
S2 = {α, β, γ, δ, ε, ζ, η, θ, ι, κ}
≅2 = {(α, ζ), (α, ι), (β, γ), (β, ε), (γ, δ), (γ, ε), (ζ, θ), (η, κ), (θ, ι)}
S2/≅2* = {{α, ζ, θ, ι}, {β, γ, δ, ε}, {η, κ}}
S3 = {♠, ♣, ♥, ♦}
≅3 = {}
S3/≅3* = {{♠}, {♣}, {♥}, {♦}}
S4 = {Α, Β, Γ, Δ, Ε, Ζ, Η, Θ, Ι, Κ, Λ}
≅4 = {(Α, Ε), (Β, Ζ), (Γ, Η), (Δ, Θ), (Ε, Ι), (Ζ, Κ), (Η, Λ), (Θ, Α), (Ι, Β), (Κ, Γ), (Λ, Δ)}
S4/≅4* = {{Α, Β, Γ, Δ, Ε, Ζ, Η, Θ, Ι, Κ, Λ}}

Here's another connected components question, with the difference that it doesn't ask for the members of the components. Not sure if everyone would consider that a duplicate.

I like the idea of having a dedicated (and separate) connected components challenge that asks for the actual components and not just their number. But since this challenge is just that, I don't think it benefits from being wrapped in a lot of notation about equivalence relations. That's a nice application, but it increases the entry barrier for people without that kind of background unnecessarily.

@MartinBüttner Actually, it was the intent to have a challenge about relations where you can discover the relationship to graph theory by thinking about the problem. But of course, you had to go and spoil it immediately. Anyway, that's part of the reason why I don't like that they took out that standard loophole. If you have to specify the loophole explicitly, you take away the chance for readers to discover the connections themselves.

@FUZxxl That's a noble intent, but I don't think there's much to discover here. Even if you never think about the relation to graphs and just implemented the first solution that came to your mind, you'd still have computed the connected components of a graph, because the problems are completely equivalent. It's not like it's an interesting shortcut to the problem that can be discovered, it's just a different way to present it. I don't think that's a good reason to artificially make the problem more complicated than it needs to be.

Another thing: the Unicode stuff is a nice alternative to LaTeX but I think it might hinder the (technical) accessibility of the spec. Someone who can't display all of the characters will have no clue what's going on, and in particular, it's impossible to copy the test cases into a potential solution. Everyone will have to replace the letters with numbers manually (unless they're using Mathematica I guess), before they can use the test cases. If you used numbers to identify the elements, then apart from substituting some delimiters, most people could use the test cases out of the box.

@MartinBüttner I can understand that you have a different philosophy when it comes to questions. My (recent) questions are all about finding relationships between seemingly unrelated things. Also, it's going to be tricky to solve this question without seeing the relationship with graphs which is why I'm asking.

@MartinBüttner If I had chosen an ASCII based format, all but a few persons had to change the format. This way, all have equal work and it looks nicer. Feel free to use numbers in test cases in your challenges. I like to do it this way.

@MartinBüttner More test cases added. BTW, I specifically restrict myself to symbols representable as html entities as to only use symbols supported in all browsers.

It's not about the browser, but about whether the font includes those characters.

@MartinBüttner These characters are extremely likely to be available if non-ASCII is supported at all due to them being part of HTML 4.

The "hull" terminology is new to me, and Google search results for "transitive hull" seem only to give pages which talk about "transitive closure" without mentioning the word "hull" anywhere. I think that's fairly good evidence that it would be clearer to talk about closures than hulls.

@PeterTaylor Sorry. This thing is called transitive Hülle in German and I assumed it was called the same in English. Let me fix this.

@cairdcoinheringaahing Thank you for your attempt at redoing the layout in MathJax.  I am not really a fan of some of the layout decisions you made, so I have reverted your edit for now.  Is it mandatory to use MathJax?  If yes, please let me know so I can manually copy edit the question in an appropriate manner.

@FUZxxl No, it isn't mandatory. As Martin said 5 years ago, Mathjax generally formats stuff "better" (at least, in my opinion), so I've updated multiple older challenges to use it. If you prefer it this way, there's nothing wrong with that however :)

@cairdcoinheringaahing Thank you for your effort.  I hope it works better for the other questions.  The formatting with this one was really wonky, partially because you defined the ≅ in a really weird way.  What's wrong with using \mathrel{...}?

I just used the pre-defined \cong command. I don't see any difference between the two: $\mathrel{≅} : \cong$

Pyth, 50 29 bytes
JchQ1FNeQAmf/@JTd0N XGJ.(JH;J

Input is expected to be a list of two elements where the first element is a list of all the objects in S, and the second element is a list of all the members in ≅, represented as lists. So for the first example, the input is
[["A", "B", "C", "D", "E", "F", "G", "H"], [["A", "B"], ["B", "C"], ["B", "E"], ["D", "G"], ["E", "H"]]]

Explanation:
                               Implicit assignment of Q to input, so head(Q) is S and end(Q) is ≅
JchQ1                          Assign J to chop(head(Q),1) e.g. [1,2,3] => [[1],[2],[3]]
     FNeQ                      For N in end(Q)
         A                       Assign [H,G] to following list
          m       N                Map following function over N
           f     0                   Return first T where following function of T starting at 0,1,2... is truthy
            /@JTd                      lambda d: true if d is J[T]
                    XGJ.(JH;     Append J[H] to J[G] and pop J[H]
                            J  Print J

Note that if transitive or reflexive members (i.e. redundant) members of ≅ are included, my code should output junk.
You can try it out here.


text:
Building a Metronome
Introduction
Some days ago I needed a metronome for something. I had none available so I downloaded an app from the App Store. The app had a size of 71 MB!!!
71 MB for making tic-toc...?!
So code-golf came into my mind and I was wondering if some of you guys could improve this.
Challenge
Golf some code that outputs some sound. It's pretty irrelevant what kind of sound. If required create some sound file... but a System beep will do the job as well. (Here is some sound I created... nothing special.)
Input: The beats per minute the metronome outputs.

Example
This is a non-golfed Java-version! It's just to show you the task.
public class Metronome {
  public static void main(String[] args) throws InterruptedException {
    int bpm = Integer.valueOf(args[0]);
    int interval = 60000 / bpm;

    while(true) {
        java.awt.Toolkit.getDefaultToolkit().beep();
        // or start playing the sound
        Thread.sleep(interval);
        System.out.println("Beep!");

    }
  }
}

Rules
You may not use external libaries, only tools of the language itself are allowed.
Only the bytes of the source code count... not the sound file.
This is code-golf, so the submission with the least amount of bytes wins!

EDIT:
Example output: So something like this would be the output for 120 bps: link

Can you add a few examples for I/O (record some sound and upload it, post the links here)?

What kind of I/O example do you mean?
P.S. There is already some sound I created, look under Challange ;)

Oh, I know about that. It's just that we typically show a few input/output examples.

Oh, ok... I'll edit the question.

Question: when you say "external libraries", does that include the libraries that are suggested with the language? (I won't use this, but an example is in Vitsy wherein I can access shell or JS (but JS is builtin))

Is the answer allowed to run out of memory or blow the call stack at some point?

Are command line options for an interpreter counted / allowed?

Can we use external audio sounds?

@DOWNGOAT: Of course you can! You can use the file I uploaded (see question) or use another sound. This is not important.

@ChatterOne Yes. Count how many bytes you need to add to the invocation which is usually between 1 and 3 bytes for single-character flags.

@ETHproductions: Yes, you can. But it's even shorter if you download and rename them, isn't it?

Can we get the input speed from a file?

@Doᴡɴɢᴏᴀᴛ: Yes, I did not specify the input.

Can you add a leaderboard snippet in?

I suspect the majority of that app you downloaded is pretty graphics and sound effects.  It's like those flashlight apps that do nothing but turn the screen all white but still manage to somehow use up tens of MB...

What's the requirement on accuracy? In your sample, both beep() and console output aren't exactly instant IIRC. Neither sleep() is known for beeing accurate.

Mathematica, 26 bytes
Pause[Beep[];60/#]~Do~∞&

Do is normally used as a "for" loop in the narrowest sense: repeat this piece of code for each i from x to y... or even just repeat this piece of code n times. Instead of a number n we can give it infinity though to create an infinite loop. The loop body is Pause[Beep[];60/#] which is just a golfy way of writing Beep[];Pause[60/#] where # is the function argument.
If it's admissible for the solution to blow up the call stack eventually, we can save one byte with a recursive solution:
#0[Beep[];Pause[60/#];#]&

I didn't know that ~Do~∞ was possible. A For loop only got me to 29 bytes. (Also, I personally believe that the 26-byte version is the only valid one.)

@LegionMammal978 Unfortunately, ~Do~∞ doesn't seem to work when the ∞ comes from a variable. (I tried using that when golfing your truth machine.)

Attributes[Do] includes HoldAll, so my guess is that _~Do~∞ has a special evaluation pattern.

@LegionMammal978 It seems more like variables do, because the error message for Do[...,a] where a holds infinity actually shows the call as Do[...,{a}].

Pyth, 11 10 9 bytes
Thanks to Adnan for reminding me about #.
#C7.dc60Q

Forever (#), print Char code 7. Then sleep (.d) 60 seconds divided by (c) input (Q).

@Adnan Forgot about that one. Thanks.

Do you need the space?

@ThomasKwa Yes. IIRC 7. would be parsed as a number.

@CᴏɴᴏʀO'Bʀɪᴇɴ The problem is that Pyth would try to print the None returned by .d as .d is also the "get date" function. (If spamming empty lines to the console is allowed, then the space is not needed.)

Oh. #pythnoob

@CᴏɴᴏʀO'Bʀɪᴇɴ Hold on. Apparently Nones are not implicitly printed. Profit

@Pietu1998 I thought of this sort of thing, actually.

I couldn't get .d to sleep when i tried. It kept printing unix time

@busukxuan Are you using the latest version of Pyth? Try doing git pull in the installation directory. Sleeping was added somewhat recently. (Also, UNIX timestamp is .d0 which should never happen with this code.)

I actually downloaded it 5days ago

JavaScript, 36 45 42 41 34 bytes
Saved 1 byte thanks to @RikerW
Saved 1 byte thanks to @ETHproductions
n=>{for(;;sleep(60/n))print("\7")}

This is a function.
If I use `\7`, SpiderMonkey complains octal literals are deprecated.
Alternative, 31 bytes
n=>{for(;;sleep(60/n))print``}

The problem is the unprintables are stripped but this should work.

Dammit, I was just about to post something like this. I'm still going to post it (because it uses node and all) because I use a different approach.

If you look it from the way I asked the question, the recursive solution would not be possible. Metronomes are made for working and working... not for crashing after some time.

@PEAR this shouldn't crash because no variable is being increments. The only thing that might cause it to crash is the terminal buffer except on modern computers that could take > 50-100 years I think

What environment does this run under? I've tried chrome and Node.js, but I can't get it to work.

@starbeamrainbowlabs this uses the JavaScript shell (SpiderMonkey)

You mean in firefox?

@starbeamrainbowlabs no, the SpiderMonkey shell.

Oh, right! I've never heard of it. I'll have to check it out!

On Chrome, this pulls up the prompt to print a hardcopy of the webpage

Bash, 53 55 41 bytes
Thanks to @Dennis for shaving off 14 bytes1
Okay, truth time: I'm terrible at golfing bash. Any help would be so very appreciated.
echo " ";sleep `bc -l<<<60/$1`;exec $0 $1
      ^ That's ASCII char 7
1 Holy crap. No wonder nobody can outgolf Dennis.

Is while 1 possible?

@PEAR Nupe - already tried that.

while printf \\a perhaps?

This doesn't work since bash uses integer division. You'll need to use bc.

The BEL character isn't special to Bash, so you don't need the quotes. 2. If you read the input as a CLA, you don't need read. 3. echo exists with code 0, so you can use that statement instead of true.

Even better: Use exec $0 $1 instead of the while loop.

JavaScript ES6 (browser), 43 bytes
This may be stretching the rules:
x=>setInterval('new Audio(1).play()',6e4/x)

Give this function a name (e.g. F=x=>...) and enter it in the browser console on this page. Then call the function with your bps, e.g. F(60), and wait for the magic to happen. :-)
Why does this work? Well, b.html is in the same folder as a file named 1, which is the sample sound file from the OP. I'm not sure if this is within the rules (I guess it's like the shell version; it needs to be run in a specific environment), but it was worth a shot.
Safer version, 57 bytes
If the above code isn't allowed for some reason, try this instead:
x=>setInterval('new Audio("//ow.ly/Xrnl1").play()',6e4/x)

Works on any page!

This is an intersting solution. It's even shorter when you download and rename the file, isn't it?

@PEAR That would be shorter, but then it would need its own webpage with the sound file in the same folder to run.

Oh, it's JavaScript xD... you're right

@PEAR There, I did it. Is this new solution within the rules?

Huh. You could specify that it is JS with the certain webpage. It's a preexisting interpreter, so it's a valid language.

Hey, it works :)

Python, 68 67 57 bytes
Saved 1 byte thanks to @FlagAsSpam
Saved 9 bytes thanks to @Adnan
import time
a=input()
while 1:print"\7";time.sleep(60./a)

Also it took 2 bytes less after converting line endings to UNIX format.
Older version, that actually takes bpm as command line argument (66 bytes):
import sys,time
while 1:print"\7";time.sleep(60./int(sys.argv[1]))

Can't you do print"\7";? I'm not sure, but I'm pretty sure that works.

@Andan No, input() requests input from user. I don't know if that's considered a valid input. Also conversion to number is needed anyway.

How about a=input() and a replacing int(sys.argv[1])? I've always thought that Python 2 automatically evaluates input and therefore doesn't need the int conversion, but I may be wrong.

@Andan input() actually does auto evaluate. I forgot about that feature. It's rather unpythonic though - probably a legacy from old times.

Can time.sleep(60./a) be replaced with time.sleep(60./input()), while completely removing a=input()?

@VoteToSpam No, that would ask user for input on every iteration

@webwarrior Oh... yeah... I can code...

You can save another byte by literally using the BEL character instead of \7 in your code.

05AB1E, 31 bytes
Code:
I60s/[7ç?D.etime.sleep(#.pop())

If I had a built-in for waiting N seconds, this could have been 11 bytes. Unfortunately, this is not the case. Here is the explanation:
I                               # Push input
 60                             # Push 60
   s                            # Swap the top 2 items
    /                           # Divide the top 2 items
     [                          # Infinite loop
      7ç                        # Push the character \x07
        ?                       # Output it, which give a sound
         .e                     # Evaluate the following as Python code
           time.sleep(       )  # Wait for N seconds
                      #         # Short for stack
                       .pop()   # Pop the last item

Uses the ISO 8859-1 encoding.

This must be one of the first 05AB1E answers o.Ô It looks very weird to see the time.sleep and .pop() in the middle of the code like that. ;)

osascript, 39 bytes
on run a
repeat
beep
delay 60/a
end
end
There is literally a command called beep? Sweeeet!
Runnable only on Mac OS X due to restricted license, but to run, do:
osascript -e "on run a
repeat
beep
delay 60/a
end
end" bpm

AutoIt, 56 bytes
Func _($0)
While Sleep(6e4/$0)
Beep(900,99)
WEnd
EndFunc

Vitsy, 14 bytes
a6*r/V1m
<wVO7
Verbose mode (interpreter coming soon):
0:                              // a6*r/V1m
push a; // 10
push 6;
multiply top two; // 60
reverse stack; // bpm on top
divide top two; // bpm/60
save/push permanent variable;
push 1;
goto top method; // goes to 1
1:                              // <wVO7
go backward; // infinite loop, from the bottom of 1
wait top seconds;
save/push permanent variable; // pushes the bpm in terms of seconds of delay
output top as character;
push 7;
Basically, I use the w operator to wait a certain number of seconds as specified by bpm/60, wrapped in an infinite loop. Then, I make noise with the terminal output of ASCII character 7 (BEL).

Looks nice, but how can I test this? :)

@PEAR You'll have to download the interpreter (forgot to link it in the title). Save it in a file and run it with java -jar Vitsy.jar <filename>.

C#, 118 bytes
class A{static int Main(string[]a){for(;;System.Threading.Thread.Sleep(60000/int.Parse(a[0])))System.Console.Beep();}}

Basic solution.

Why not print ASCII char 7?

@FlagAsSpam It's longer: The system beep uses System.Console.Beep();, and printing the character uses System.Console.Write('<\a character>');.

Woah. That's a lot to write a character.

Java, 103 82 bytes
Thanks to @Justin for shaving off 21 bytes!
Oh, geez.
void x(int b)throws Exception{for(;;Thread.sleep(60000/b))System.out.print('\7');}
Method and golfed version of the sample program.

Why not System.out.print('\7'); instead of the java.awt.Toolkit.getDefaultToolkit().beep();?

@Justin \ is solely for escaping regex characters.

no the backslash is an escape sequence. '\7' is the bell character, which makes a sound when it is printed out

@Justin Huh. I've always thrown errors on that (when using double quotes). My mistake. Thanks! :D

GMC-4 Machine Code, 21.5 bytes
The GMC-4 is a 4-bit computer by a company called Gakken to teach the principles of assembly language in a simplified instruction set and computer. This routine takes input in data memory addresses 0x5D through 0x5F, in big-endian decimal (that is, one digit per nibble).
The algorithm is basically adding the input to memory and waiting 0.1s, until it's at least 600, and then subtracting 600 and beeping, in an infinite loop. Since the GMC-4 has a bunch of register swap functions but no register copy functions, this is done the hard way.
In hex (second line is position in memory):
A24A14A04 80EC AF5A2EF AE5A1EF AD5A0EF 8A6 F2AF09 86ADEEE9F09
012345678 9ABC DEF0123 4567890 ABCDEF0 123 456789 ABCDEF01234

In assembly:
    tiy 2     ;ld y, 0x2
    AM        ;ld a, [0x50 + y]
    tiy 1
    AM
    tiy 0
    AM
start:
    tia 0     ;ld a, 0x0
    cal timr  ;pause for (a+1)*0.1 seconds
    tiy F
    MA        ;ld [0x50 + y], a
    tiy 2
    cal DEM+  ;add a to [0x50 + y]; convert to decimal and carry.
    tiy E     ;do the same for the second digit
    MA
    tiy 1
    cal DEM+
    tiy D     ;and the third.
    MA
    tiy 0
    cal DEM+
    tia A
    M+
    jump beep
    jump start
beep:
    tia 6
    tiy D
    cal DEM-
    cal SHTS  ;'play short sound'
    jump start

Disclaimer:
I don't actually own a GMC-4. I've meticulously checked this program with documentation from online, but I may have made a mistake. I also don't know the endianness. It looks like the GMC-4 is big-endian, but I'm not sure. If anyone owns a GMC-4 and can verify this/tell me the endianness of the GMC-4, I'd much appreciate it.

C, 48 bytes
void f(int b){while(printf(""))Sleep(60000/b);}
                            ^ literal 0x07 here

A Windows-only solution (Sleep() function, to be specific).
I also (ab)used the fact that printf() returns the number of characters printed to use it as infinite loop condition.
There IS a character between double-quotes in printf() call, but it is not displayed here for some reason. If in doubt, copy and paste into Sublime Text 2 or Notepad++, the character will be displayed as BEL.
This started as a C++ solution but it kinda fell into the C-subset of C++ (because, you know, Sleep() is a bit shorter than std::this_thread::sleep_for(std::chrono::milliseconds())) and printf() is shorter than std::cout<<).

AppleScript 94 bytes
I know I'm pretty late, and this is my first post here, but whatever.

display dialog""default answer""
set x to 60000/result's text returned
repeat
beep
delay x
end
Ungolfed:

display dialog "" default answer ""
set x to 60000 / (result's text returned)
repeat
    beep
    delay x
end repeat

Hey, new answers :)
Unfortunatly I'm unable to try your post unless I have no Mac ;) - but thanks a lot

@PEAR You're welcome. :)

Welcome to Programming Puzzles and Code Golf. This is good answer, +1. Please keep answering!

VBScript, 113 66 bytes
a=InputBox("")
Do
WScript.Echo(Chr(7))
WScript.Sleep(60000/a)
Loop

This program is simple enough; it takes input, echoes the BEL character, and waits. Thanks to Niel for shaving off almost half the program!

What's wrong with WScript.Echo CHR(7)? Also, did you mean 60000?

@Neil Ah, yes. forgot about those.;

Ruby, 37 33 bytes
m=->b{loop{puts"\7"
sleep 6e1/b}}

Pretty straightforward.
This is a lambda function. If you wanted 60 bpm, you'd do: m[60].

Theoretically $><<?\a should also work for the beep. And no need to give a name for your proc (all JavaScript solutions with fat arrow function also leave it unassigned), you can call it anonymously too: ->b{loop{$><<?\a;sleep 6e1/b}}[60].

@manatwork I only have Ruby 2.x, so I couldn't test the ?\a; do you have Ruby 1.x? If so, can you test that this works?

Well, I have a Ruby 1.9.3 and the code raises no error with it. But I have another problem with the testing: no beep on my machine. Neither Ruby nor anything else. Set something once, no idea what.

Japt, 30 bytes
6e4/U i`?w Au¹o('../1').play()

The ? should be the literal byte 9A. Test it online! (Sorry about the pop-up delaying the first few beats; this will be removed soon.)
How it works
6e4/U i"new Audio('../1').play()  // Implicit: U = input bps
6e4/U                             // Calculate 60000 / U.
      i                           // Set a timed event every that many milliseconds,
       "new Audio('../1').play()  // running this code every time.
                                  // ../1 is the path to the file used in my JS entry.

Perl 5, 36 bytes
{{$|=print"\a";sleep 60/$_[0];redo}}

A subroutine; use it as
sub{{$|=print"\a";sleep 60/$_[0];redo}}->(21)

sleep is in seconds, so you can't have more than 60 beeps per minute, not sure if that's a requirement. Also, you can probably keep the same byte count but have a full program by doing something like: $|=<>;{print"\a";sleep 60/$|;redo} (can't test it right now).

@ChatterOne, according to its documentation, you're right about sleep. But it worked for me.

Mumps, 18 bytes
R I F  H 60/I W *7

Read the BPM into variable I, then F {with two spaces after} is an infinate loop. Halt for 60 seconds / BPM, then write $CHR(7) {Ascii: BEL} to standard output, giving the audio output required, then restart at the infinite loop.

Java, 321 chars
Sounds very good. Works only on systems with MIDI support.
import javax.sound.midi.*;import java.util.*;class A{public static void main(String[] a) throws Exception{int d=new Scanner(System.in).nextInt();Synthesizer b=MidiSystem.getSynthesizer();b.open();MidiChannel c=b.getChannels()[0];c.programChange(116);while(true){c.noteOn(0,100);Thread.sleep((int)(d/.06));c.noteOff(0);}}}

.

Looks nice, but this does not work for me: http://pastebin.com/0CbGYkU0

@PEAR fixed. I forgot a cast.

@PEAR and an import

@PEAR, i had swapped some ops because of no sound

ChucK, 90 bytes
White noise that is turned on and off every two ticks.
60./Std.atoi(me.arg(0))*1000=>float s;while(1){Noise b=>dac;s::ms=>now;b=<dac;s::ms=>now;}

Explanation
60./Std.atoi(me.arg(0)) //Convert the input to an int and divide 60 by it
*1000                   //Multiply by 1000 (in order to avoid s::second)
=>float s;              //Store it as a float in variable s
while(1)                //Forever,
{Noise b=>dac;          //Connect a noise generator b to the audio output
s::ms=>now;             //Wait for s milliseconds
b=<dac;                 //Disconnect b from the audio output
s::ms=>now;}            //Wait for s milliseconds

This is made to turn on the sound on a beat, then turn it off on the beat after.
98 93 byte version (fancier)
White noise played for 10 milliseconds per tick.
60./Std.atoi(me.arg(0))*1000-9=>float s;while(1){Noise b=>dac;10::ms=>now;b=<dac;s::ms=>now;}

This is made to be a click instead of constant noise being turned on and off.

Jolf, 7 bytes, noncompeting
I added sounds after this very fine challenge was made.
TΑa/Αaj
T       set an interval
 Αa      that plays a short beep (Α is Alpha)
   /Αaj  every 60000 / j (the input) seconds. (Αa returns 60000)

If you so desire to clear this sound, take note of the output. Say that number is x. Execute another Jolf command ~CP"x", and the interval will be cleared.

Stax, 17 bytes
ü7»♥O╚⌂╥☻≈OyM╜Δ∩`

or, unpacked:
4|A48*x/W2|A]pc{| }*

The program outputs bytes that, when fed through the command line tool aplay with default setting, produce a metronome noise.  The input is used as bpm
example:
example-stax-interpreter metronome.stax -i "60" | aplay

You should hear a horrible beeping noise at the desired bpm

Zsh, 32 bytes
<<<$'\a'
sleep $[60./$1]
. $0 $1

Based on the leading bash answer, but sources instead of execs. The TIO link sources $0:a because of how the original file is executed, but it will work without it.
Try it online!

You're late to the party but this looks like really fine solution!

I know I'm late, but I just felt like golfing today. Decided to check on the music tag for fun, and found this challenge.  Good one, btw!

Bash + bc + ><>, 44 bytes
Playing on the fact that the ><> interpreter lets you define a tick time :
python fish.py -t $(bc -l<<<"2/$1/60") -c 7o

The ><> code is 7o and should output the BEL character, producing a system beep. It will loop until interrupted.
The -t value is set to (2 / RPM ) / 60  so that the whole code is played RPM * 60 times per second.

Thanks a lot for a new answer after some amount of time after publishing. Doesn't work for me :( Not sure if a problem of my system or something else. I downloaded the fish.py from GitHub and executed your commad (openSUSE). Got this error:
(standard_in) 1: syntax error
usage: fish.py [-h] (
Have you got bc installed? It looks like the $(bc -l<<<"2/$1/60") did not produce any output. I'll add it to the list of languages of the answer. I haven't been able to fully test my answer yet, so there might be some kind of error too.

SmileBASIC, 26 bytes
INPUT B$BGMPLAY@8T+B$+"[C]

It can play any general midi instrument, though anything above 9 will use more bytes.


text:
The autopilot mode
A helicopter starting at the top left corner is descending (in a 2D space, for the purpose of this question) towards the ground. It has an autopilot mode and a manual mode.
The autopilot mode behaves as follows:

If the space directly below is free, descend to it.
Otherwise move a step left or right, totally at random. (It may move multiple steps in this manner.)

And it keeps repeating these two steps until it hits the ground. The manual mode is more smart and will find the optimal path to the ground, even if this requires moving upwards, or some skillful manoeuvring.
Your job is to determine if

The autopilot will pass in the given scenario,
The autopilot might fail in the given scenario,
The autopilot will fail, but the manual mode will pass, or
Both modes will fail (there is no valid path to the ground).

Input

Given scenario as a 1d or 2d non-empty array, using two different characters to represent free and blocked spaces. Punctuation optional.
Optional: dimensions of array

Output
One of four predefined characters indicating which of the cases has occurred.
Sample data
Using 0 (empty) and 1 (blocked) in input, 1 2 3 4 in output (as numbered above)
0 0 0 0
0 1 0 0
0 0 0 1
1 1 0 0

Output: 1
0 0 1 0
1 0 0 1
0 0 0 0
0 1 1 0
0 0 0 1

Output: 2 (The helicopter will encounter the 1 in the fourth row, and it is possible it will trap itself at the end of row 5, if on autopilot mode)
0 0 0 1 0
0 1 1 0 0
0 1 0 0 0
0 0 0 1 0
1 1 1 1 0

Output: 3 (This requires moving upwards, so the autopilot fails)
1 0 0
0 0 0

Output: 4
0 0 0 0 1
1 1 1 0 0
1 0 0 1 0
0 1 0 0 0
0 0 1 1 1

Output: 4

@MartinBüttner Done. As a side-note, do you prefer people to post in the sandbox, or to directly post and have their errors corrected? The second option is simpler, so unless there's some incentive not to, I can't imagine why I'd follow option one.

I personally prefer the sandbox, because it gives people more time to think about potential errors, loopholes or missing test cases, before people start working on the challenge. If someone posts an early answer to a flawed challenge, then you can't really fix the challenge without invalidating existing answers.

Also - are the inputs always characters, or can they be booleans/integers/etc?  And output - can that be integer, or is it required to be a character?

Ruby, 259
I had a lot of fun with this.  Thank you!  grid challenges tend to be excellent fun with interesting challenges.  This assumes that "characters" in the question can be integers.
I think the major points of improvement here are:

The creation of r
The ghastly ternary abuse on the third line can likely be made into a more-ghastly, but terser something.

->a,h,w{f=->l,s=0,y=[0]{r=w-2<s%w ?w:1,1>s%w ?w:-1,w
v=(l ?r+[-w]:a[s+w]==0?[w]:r).map{|d|a[m=s+d]==0&&!y[m]?m:p}-q=[p]
a[s]>0?q:s/w>h-2?8:v[0]?v.map{|o|f[l,y[o]=o,y]}.flatten-q :r.any?{|i|a[s+i]<1}?p: !0}
g=f[p]
[8,g[0]&&g.all?,g.any?,f[8].any?,!p].index !p}

Ungolfed (slightly out of date, but real close):
# a is a one-dimensional array of 0s and 1s, h is height, w is width
->a,h,w{
  # f recursively walks the array and returns true/false/nil for each path.
  #    True means we can reach ground.
  #    False means we are stuck in a local minimum and cannot escape
  #    Nil means we reached a local dead-end and need to backtrack.
  # l: {true=>"manual", false=>"autopilot"}
  # s: the position index
  # y: an array of booleans - true-ish means we've visited that square before
  #         (this is to prevent infinite loops, esp in manual mode)
  f=->l,s=0,y=[0]{
    # d: all the legal deltas from s (maximally, that's [1,-1,w,-w], aka [LRDU])
    # r: but the right and left get tricky on the edges, so let's pre-calculate those
    #    we'll default to "down" if "left" or "right" are illegal
    r=[w-2<s%w ?w:1,1>s%w ?w:-1]
    # if manual, [LRDU]; if auto, and you can go down, [D]. else, [LR]
    d=l ?r+[w,-w]:a[s+w]==0?[w]:r
    # v: the legal deltas that you can go to from s (that is, unvisited and unblocked)
    v=d.map{|d|a[m=s+d]==0&&!y[m]?m:p}-[p]

    a[s]>0 ? [p]     # if we're currently blocked, return [nil] (this is only the case when a[0]==1)
      : s/w>h-2 ? !p # if we're at the bottom, return true
        : v[0] ?     # if we have a place to go....
        v.map{|o|f[l,y[o]=o,y]}.flatten-[p] # recurse with each step.
                                            # y[o]=o is a neat trick to make y[o] truthy and return o
          : r.any?{|i|a[s+i]==0} ? # otherwise, we have nowhere to go. If we could visit left/right, but have already been there
            p                      #    this is not a dead-end - return nil to remove this path
            : !!p                  # If we have a true dead-end (auto-mode with a local minimum), false
  }
  # g is the auto flight
  g=f[p]
  # finally, choose the first "true" out of:
  # 0: always 8.  Cuz why not 8?
  # 1: there is at least one auto path, and all are truthy
  # 2: any auto path is truthy
  # 3: any manual path is truthy
  # 4: true
  [8,g[0]&&g.all?,g.any?,f[!p].any?,!p].index !p
}