4 added 11 characters in body
source | link
  • The input will be a list of tuples with two elements each: the name of the current node and the name of its parent. If you don't like strings you can use arrays of chars. You can choose the order of the elements in the tuple (the node name first or the parent name first).
  • The output format can be: a list of paths as strings like ["/A/B/C/D","/A/B/E"] for the second example; a list of path nodes for each leaf, as in [["A","B","C","D"],["A","B","E"]] for the same example; or even a dictionary (something like ["A":["B":["E":[],"C":["D":[]]]]]). Or you can just print the list of paths to STDOUT.
  • There won't be nodes without a parent given explicitly.
  • The node names will be strings of alphanumeric ASCII characters [a-zA-Z0-9] of any length. So you can use any other printable ASCII character as separator if you decide to print or return the paths as strings.
  • There won't be duplicated tuples in the list.
  • There won't be cyclic paths in the list of nodes.
  • The node names are unique and case sensitive. Nodes aa and AA are not the same node.
  • If you get an empty list of nodes, return an empty list/dictionary of leaves (or just print nothing).
  • The input will be a list of tuples with two elements each: the name of the current node and the name of its parent. If you don't like strings you can use arrays of chars. You can choose the order of the elements in the tuple (the node name first or the parent name first).
  • The output format can be: a list of paths as strings like ["/A/B/C/D","/A/B/E"] for the second example; a list of path nodes for each leaf, as in [["A","B","C","D"],["A","B","E"]] for the same example; or even a dictionary (something like ["A":["B":["E":[],"C":["D":[]]]]]). Or you can just print the list of paths to STDOUT.
  • There won't be nodes without a parent given explicitly.
  • The node names will be strings of alphanumeric ASCII characters [a-zA-Z0-9] of any length. So you can use any other printable ASCII character as separator if you decide to print or return the paths as strings.
  • There won't be duplicated tuples in the list.
  • There won't be cyclic paths in the list of nodes.
  • The node names are case sensitive. Nodes aa and AA are not the same node.
  • If you get an empty list of nodes, return an empty list/dictionary of leaves (or just print nothing).
  • The input will be a list of tuples with two elements each: the name of the current node and the name of its parent. If you don't like strings you can use arrays of chars. You can choose the order of the elements in the tuple (the node name first or the parent name first).
  • The output format can be: a list of paths as strings like ["/A/B/C/D","/A/B/E"] for the second example; a list of path nodes for each leaf, as in [["A","B","C","D"],["A","B","E"]] for the same example; or even a dictionary (something like ["A":["B":["E":[],"C":["D":[]]]]]). Or you can just print the list of paths to STDOUT.
  • There won't be nodes without a parent given explicitly.
  • The node names will be strings of alphanumeric ASCII characters [a-zA-Z0-9] of any length. So you can use any other printable ASCII character as separator if you decide to print or return the paths as strings.
  • There won't be duplicated tuples in the list.
  • There won't be cyclic paths in the list of nodes.
  • The node names are unique and case sensitive. Nodes aa and AA are not the same node.
  • If you get an empty list of nodes, return an empty list/dictionary of leaves (or just print nothing).
    Tweeted twitter.com/StackCodeGolf/status/954344845828612096
3 deleted 89 characters in body
source | link
  • The input will be a list of tuples with two elements each: the name of the current node and the name of its parent. If you don't like strings you can use arrays of chars. You can choose the order of the elements in the tuple (the node name first or the parent name first).
  • The output format depends on you, as long as the paths for each leaf can be reconstructed. You can return: a list of paths as strings like ["/A/B/C/D","/A/B/E"] for the second example, or returnexample; a list of path nodes for each leaf, as in [["A","B","C","D"],["A","B","E"]] for the same example,example; or even return a dictionary (something like ["A":["B":["E":[],"C":["D":[]]]]]). Or you can just print the list of paths to STDOUT.
  • There won't be nodes without a parent given explicitly.
  • The node names will be strings of alphanumeric ASCII characters [a-zA-Z0-9] of any length. So you can use any other printable ASCII character as separator if you decide to print or return the paths as strings.
  • There won't be duplicated tuples in the list.
  • There won't be cyclic paths in the list of nodes.
  • The node names are case sensitive. Nodes aa and AA are not the same node.
  • If you get an empty list of nodes, return an empty list/dictionary of leaves (or just print nothing).
  • The input will be a list of tuples with two elements each: the name of the current node and the name of its parent. If you don't like strings you can use arrays of chars. You can choose the order of the elements in the tuple (the node name first or the parent name first).
  • The output format depends on you, as long as the paths for each leaf can be reconstructed. You can return a list of paths as strings like ["/A/B/C/D","/A/B/E"] for the second example, or return a list of path nodes for each leaf, as in [["A","B","C","D"],["A","B","E"]] for the same example, or even return a dictionary (something like ["A":["B":["E":[],"C":["D":[]]]]]). Or just print the list of paths to STDOUT.
  • There won't be nodes without a parent given explicitly.
  • The node names will be strings of alphanumeric ASCII characters [a-zA-Z0-9] of any length. So you can use any other printable ASCII character as separator if you decide to print or return the paths as strings.
  • There won't be duplicated tuples in the list.
  • There won't be cyclic paths in the list of nodes.
  • The node names are case sensitive. Nodes aa and AA are not the same node.
  • If you get an empty list of nodes, return an empty list/dictionary of leaves (or just print nothing).
  • The input will be a list of tuples with two elements each: the name of the current node and the name of its parent. If you don't like strings you can use arrays of chars. You can choose the order of the elements in the tuple (the node name first or the parent name first).
  • The output format can be: a list of paths as strings like ["/A/B/C/D","/A/B/E"] for the second example; a list of path nodes for each leaf, as in [["A","B","C","D"],["A","B","E"]] for the same example; or even a dictionary (something like ["A":["B":["E":[],"C":["D":[]]]]]). Or you can just print the list of paths to STDOUT.
  • There won't be nodes without a parent given explicitly.
  • The node names will be strings of alphanumeric ASCII characters [a-zA-Z0-9] of any length. So you can use any other printable ASCII character as separator if you decide to print or return the paths as strings.
  • There won't be duplicated tuples in the list.
  • There won't be cyclic paths in the list of nodes.
  • The node names are case sensitive. Nodes aa and AA are not the same node.
  • If you get an empty list of nodes, return an empty list/dictionary of leaves (or just print nothing).
2 edited tags
| link
1
source | link