Skip to main content
added 2 characters in body
Source Link
Wrzlprmft
  • 2.9k
  • 21
  • 36

Python – 54 52 + 67 + 7

def R(G,s,A):
    A|={s}
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A={[]}A=set()
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example. Anyway, you may want to charge 67 additional chars for the intialisation of the empty set (A={[]}A=set()) and 7 for the print line.

Python – 54 52 + 6 + 7

def R(G,s,A):
    A|={s}
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A={[]}
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example. Anyway, you may want to charge 6 additional chars for the intialisation of the empty set (A={[]}) and 7 for the print line.

Python – 54 52 + 7 + 7

def R(G,s,A):
    A|={s}
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A=set()
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example. Anyway, you may want to charge 7 additional chars for the intialisation of the empty set (A=set()) and 7 for the print line.

added 141 characters in body
Source Link
Wrzlprmft
  • 2.9k
  • 21
  • 36

Python – 5454 52 + 6 + 7

def R(G,s,A):
    A.add(A|={s)}
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A = set()A={[]}
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example. Anyway, you may want to charge 6 additional chars for the intialisation of the empty set (A={[]}) and 7 for the print line.

Python – 54

def R(G,s,A):
    A.add(s)
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A = set()
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example.

Python – 54 52 + 6 + 7

def R(G,s,A):
    A|={s}
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A={[]}
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example. Anyway, you may want to charge 6 additional chars for the intialisation of the empty set (A={[]}) and 7 for the print line.

Source Link
Wrzlprmft
  • 2.9k
  • 21
  • 36

Python – 54

def R(G,s,A):
    A.add(s)
    for n in set(G[s])-A:R(G,n,A)

R needs to be called with an empty set as an additional argument. This set contains the output, when R has finished. Example of usage:

G = {1: [2, 3], 2: [3], 3: [1], 4:[2]}
A = set()
R(G,1,A)
print A

If you consider this way of output cheating, keep in mind that it’s very normal in C, for example.